Rename iced_sentinel to iced_beacon and refactor its API
This commit is contained in:
parent
aaf396256e
commit
57033dc4d0
19 changed files with 596 additions and 438 deletions
|
|
@ -118,6 +118,9 @@ where
|
|||
/// The data needed to initialize your [`Application`].
|
||||
type Flags;
|
||||
|
||||
/// Returns the unique name of the [`Application`].
|
||||
fn name() -> &'static str;
|
||||
|
||||
/// Initializes the [`Application`] with the flags provided to
|
||||
/// [`run`] as part of the [`Settings`].
|
||||
///
|
||||
|
|
@ -250,6 +253,10 @@ where
|
|||
{
|
||||
type Flags = A::Flags;
|
||||
|
||||
fn name() -> &'static str {
|
||||
A::name()
|
||||
}
|
||||
|
||||
fn new(flags: Self::Flags) -> (Self, Command<A::Message>) {
|
||||
let (app, command) = A::new(flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,12 @@ where
|
|||
type Renderer = Renderer;
|
||||
type Executor = executor::Default;
|
||||
|
||||
fn name() -> &'static str {
|
||||
let type_name = std::any::type_name::<State>();
|
||||
|
||||
type_name.split("::").next().unwrap_or(type_name)
|
||||
}
|
||||
|
||||
fn load(&self) -> Command<Self::Message> {
|
||||
Command::none()
|
||||
}
|
||||
|
|
@ -211,6 +217,10 @@ impl<P: Definition> Program<P> {
|
|||
)
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
self.program.title(&self.state)
|
||||
}
|
||||
|
|
@ -431,6 +441,8 @@ pub trait Definition: Sized {
|
|||
/// The executor of the program.
|
||||
type Executor: Executor;
|
||||
|
||||
fn name() -> &'static str;
|
||||
|
||||
fn load(&self) -> Command<Self::Message>;
|
||||
|
||||
fn update(
|
||||
|
|
@ -484,12 +496,16 @@ fn with_title<P: Definition>(
|
|||
type Renderer = P::Renderer;
|
||||
type Executor = P::Executor;
|
||||
|
||||
fn title(&self, state: &Self::State) -> String {
|
||||
self.title.title(state)
|
||||
}
|
||||
|
||||
fn load(&self) -> Command<Self::Message> {
|
||||
self.program.load()
|
||||
}
|
||||
|
||||
fn title(&self, state: &Self::State) -> String {
|
||||
self.title.title(state)
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn update(
|
||||
|
|
@ -553,6 +569,10 @@ fn with_load<P: Definition>(
|
|||
Command::batch([self.program.load(), (self.load)()])
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn update(
|
||||
&self,
|
||||
state: &mut Self::State,
|
||||
|
|
@ -621,6 +641,10 @@ fn with_subscription<P: Definition>(
|
|||
(self.subscription)(state)
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn load(&self) -> Command<Self::Message> {
|
||||
self.program.load()
|
||||
}
|
||||
|
|
@ -686,6 +710,10 @@ fn with_theme<P: Definition>(
|
|||
(self.theme)(state)
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn load(&self) -> Command<Self::Message> {
|
||||
self.program.load()
|
||||
}
|
||||
|
|
@ -755,6 +783,10 @@ fn with_style<P: Definition>(
|
|||
(self.style)(state, theme)
|
||||
}
|
||||
|
||||
fn name() -> &'static str {
|
||||
P::name()
|
||||
}
|
||||
|
||||
fn load(&self) -> Command<Self::Message> {
|
||||
self.program.load()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue