Skip to content

Commit

Permalink
make items private
Browse files Browse the repository at this point in the history
  • Loading branch information
ameknite committed Mar 31, 2024
1 parent 4d5c469 commit 149eaaf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions examples/app/log_layers_ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
//! The way we will do this is via a [`mpsc`] channel. [`mpsc`] channels allow 2 unrelated
//! parts of the program to communicate (in this case, [`Layer`]s and Bevy's ECS).
//!
//! Inside the [`update_subscriber`] function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
//! Inside the `update_subscriber` function we will create a [`mpsc::Sender`] and a [`mpsc::Receiver`] from a
//! [`mpsc::channel`]. The [`Sender`](mpsc::Sender) will go into the `AdvancedLayer` and the [`Receiver`](mpsc::Receiver) will
//! go into a non-send resource called `LogEvents` (It has to be non-send because [`Receiver`](mpsc::Receiver) is [`!Sync`](Sync)).
//! From there we will use [`transfer_log_events`] to transfer log events from `LogEvents` to an ECS event called [`LogEvent`].
//! From there we will use `transfer_log_events` to transfer log events from `LogEvents` to an ECS event called `LogEvent`.
//!
//! Finally, after all that we can access the [`LogEvent`] event from our systems and use it.
//! Finally, after all that we can access the `LogEvent` event from our systems and use it.
//! In this example we build a simple log viewer.

use std::sync::mpsc;
Expand All @@ -23,17 +23,17 @@ use bevy::{

/// A basic message. This is what we will be sending from the [`CaptureLayer`] to [`CapturedLogEvents`] non-send resource.
#[derive(Debug, Event)]
pub struct LogEvent {
struct LogEvent {
message: String,
}

/// This non-send resource temporarily stores [`LogEvent`]s before they are
/// written to [`Events<LogEvent>`] by [`transfer_log_events`].
#[derive(Deref, DerefMut)]
pub struct CapturedLogEvents(mpsc::Receiver<LogEvent>);
struct CapturedLogEvents(mpsc::Receiver<LogEvent>);

/// Transfers information from the `LogEvents` resource to [`Events<LogEvent>`](LogEvent).
pub fn transfer_log_events(
fn transfer_log_events(
receiver: NonSend<CapturedLogEvents>,
mut log_events: EventWriter<LogEvent>,
) {
Expand All @@ -43,7 +43,7 @@ pub fn transfer_log_events(

/// This is the [`Layer`] that we will use to capture log events and then send them to Bevy's
/// ECS via it's [`mpsc::Sender`].
pub struct CaptureLayer {
struct CaptureLayer {
sender: mpsc::Sender<LogEvent>,
}
impl<S: Subscriber> Layer<S> for CaptureLayer {
Expand Down Expand Up @@ -77,8 +77,8 @@ impl tracing::field::Visit for CaptureLayerVisitor<'_> {
}
}
}
/// Update Subscriber
pub fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber {

fn update_subscriber(app: &mut App, subscriber: BoxedSubscriber) -> BoxedSubscriber {
let (sender, receiver) = mpsc::channel();

let layer = CaptureLayer { sender };
Expand Down

0 comments on commit 149eaaf

Please sign in to comment.