Skip to content

Commit

Permalink
unique name for each plugin instance (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Nov 22, 2022
1 parent eadc979 commit ef54a86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl<S: StateData> Plugin for ProgressPlugin<S> {
}
}

fn is_unique(&self) -> bool {
false
fn name(&self) -> &str {
&self.plugin_name
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,15 @@ pub struct ProgressPlugin<S: StateData> {
pub next_state: Option<S>,
/// Whether to enable the optional assets tracking feature
pub track_assets: bool,
// Unique name, made using the loading state
pub(crate) plugin_name: String,
}

impl<S: StateData> ProgressPlugin<S> {
/// Create a [`ProgressPlugin`] running during the given State
pub fn new(state: S) -> Self {
ProgressPlugin {
plugin_name: format!("{}({:?})", std::any::type_name::<Self>(), state),
state,
next_state: None,
track_assets: false,
Expand Down
4 changes: 2 additions & 2 deletions src/loopless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl<S: StateData> Plugin for ProgressPlugin<S> {
}
}

fn is_unique(&self) -> bool {
false
fn name(&self) -> &str {
&self.plugin_name
}
}

Expand Down

0 comments on commit ef54a86

Please sign in to comment.