3
3
//! The way we will do this is via a [`mpsc`] channel. [`mpsc`] channels allow 2 unrelated
4
4
//! parts of the program to communicate (in this case, [`Layer`]s and Bevy's ECS).
5
5
//!
6
- //! Inside the [ `update_subscriber`] function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
6
+ //! Inside the `update_subscriber` function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
7
7
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the `AdvancedLayer` and the [`Receiver`](mpsc::Receiver) will
8
8
//! go into a non-send resource called `LogEvents` (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
9
- //! From there we will use [ `transfer_log_events`] to transfer log events from `LogEvents` to an ECS event called [ `LogEvent`] .
9
+ //! From there we will use `transfer_log_events` to transfer log events from `LogEvents` to an ECS event called `LogEvent`.
10
10
//!
11
- //! Finally, after all that we can access the [ `LogEvent`] event from our systems and use it.
11
+ //! Finally, after all that we can access the `LogEvent` event from our systems and use it.
12
12
//! In this example we build a simple log viewer.
13
13
14
14
use std:: sync:: mpsc;
@@ -23,17 +23,17 @@ use bevy::{
23
23
24
24
/// A basic message. This is what we will be sending from the [`CaptureLayer`] to [`CapturedLogEvents`] non-send resource.
25
25
#[ derive( Debug , Event ) ]
26
- pub struct LogEvent {
26
+ struct LogEvent {
27
27
message : String ,
28
28
}
29
29
30
30
/// This non-send resource temporarily stores [`LogEvent`]s before they are
31
31
/// written to [`Events<LogEvent>`] by [`transfer_log_events`].
32
32
#[ derive( Deref , DerefMut ) ]
33
- pub struct CapturedLogEvents ( mpsc:: Receiver < LogEvent > ) ;
33
+ struct CapturedLogEvents ( mpsc:: Receiver < LogEvent > ) ;
34
34
35
35
/// Transfers information from the `LogEvents` resource to [`Events<LogEvent>`](LogEvent).
36
- pub fn transfer_log_events (
36
+ fn transfer_log_events (
37
37
receiver : NonSend < CapturedLogEvents > ,
38
38
mut log_events : EventWriter < LogEvent > ,
39
39
) {
@@ -43,7 +43,7 @@ pub fn transfer_log_events(
43
43
44
44
/// This is the [`Layer`] that we will use to capture log events and then send them to Bevy's
45
45
/// ECS via it's [`mpsc::Sender`].
46
- pub struct CaptureLayer {
46
+ struct CaptureLayer {
47
47
sender : mpsc:: Sender < LogEvent > ,
48
48
}
49
49
impl < S : Subscriber > Layer < S > for CaptureLayer {
@@ -77,8 +77,8 @@ impl tracing::field::Visit for CaptureLayerVisitor<'_> {
77
77
}
78
78
}
79
79
}
80
- /// Update Subscriber
81
- pub fn update_subscriber ( app : & mut App , subscriber : BoxedSubscriber ) -> BoxedSubscriber {
80
+
81
+ fn update_subscriber ( app : & mut App , subscriber : BoxedSubscriber ) -> BoxedSubscriber {
82
82
let ( sender, receiver) = mpsc:: channel ( ) ;
83
83
84
84
let layer = CaptureLayer { sender } ;
0 commit comments