Skip to main content

Core

Struct Core 

Source
pub struct Core {
    pub tree: Tree,
    pub caches: SharedState,
    pub active_subscriptions: HashMap<String, Vec<SubscriptionEntry>>,
    pub default_event_rate: Option<u32>,
    pub default_text_size: Option<f32>,
    pub default_font: Option<Font>,
    pub cached_theme: Option<Theme>,
    pub cached_theme_chrome: ThemeChrome,
    pub effect_stubs: HashMap<String, Value>,
    pub validate_props: Option<bool>,
    /* private fields */
}
Expand description

Pure state core, decoupled from the iced runtime.

Owns the retained UI tree, widget caches, active subscriptions, and global rendering defaults. The host calls apply with each incoming message and executes the returned CoreEffects.

Fields§

§tree: Tree

The retained UI tree (snapshots replace it, patches update it).

§caches: SharedState

Caches for stateful widgets (text_editor content, markdown items, etc.).

§active_subscriptions: HashMap<String, Vec<SubscriptionEntry>>

Active event subscriptions: kind -> list of entries. Each kind can have multiple entries with different tags and optional window scoping.

§default_event_rate: Option<u32>

Global default event rate from Settings (events per second). None = no limit (full speed).

§default_text_size: Option<f32>

Global default text size from Settings.

§default_font: Option<Font>

Global default font from Settings.

§cached_theme: Option<Theme>

Cached resolved theme from the root node’s theme prop. Only re-resolved when the raw JSON value changes.

§cached_theme_chrome: ThemeChrome§effect_stubs: HashMap<String, Value>

Registered effect stubs: kind -> response value. When an effect request matches a stub, the renderer returns the stubbed response immediately without executing the real effect. Used for testing and scripting.

§validate_props: Option<bool>

Per-session prop-validation override.

Some(true) enables validation for this session. None falls back to the process-wide is_validate_props_enabled check (which itself defaults to cfg(debug_assertions) when no global value has been set). validate_props: false in Settings does not disable validation; it leaves the fallback in control so hosts cannot turn off debug/default validation for a session.

Implementations§

Source§

impl Core

Source

pub fn new() -> Self

Source

pub fn is_validate_props_enabled(&self) -> bool

Resolve whether prop validation should run for this session.

A per-session true forces validation on. Otherwise the process-wide flag decides.

Source

pub fn has_subscription(&self, kind: &str) -> bool

Check whether at least one entry is registered for the given kind.

Source

pub fn matching_entries( &self, kind: &str, window_id: Option<&str>, ) -> Vec<&SubscriptionEntry>

Return all entries matching a kind, filtered by window_id. An entry matches if its window_id is None (global) or equals the event’s window_id.

Source

pub fn matching_entries_with_catchall( &self, kind: &str, catchall_kind: &str, window_id: Option<&str>, ) -> Vec<&SubscriptionEntry>

Return all entries matching a specific kind plus the catch-all SUB_EVENT kind, filtered by window_id. Useful for event emission where both specific and catch-all subscriptions should fire.

Source

pub fn subscription_rates(&self) -> impl Iterator<Item = (&str, u32)>

Collect all max_rate values from subscription entries, keyed by tag. Returns (tag, max_rate) pairs for entries that have a max_rate set. The tag includes window scope when present, so rate limiting is isolated per subscription entry.

Source

pub fn subscription_rate_tags(&self) -> impl Iterator<Item = &str>

Collect all tags that have a max_rate set.

Source

pub fn tree_hash(&self) -> String

Compute the canonical SHA-256 hash of the current tree. Returns the hex-encoded hash string, or an empty string if no tree.

Source

pub fn apply(&mut self, message: IncomingMessage) -> Vec<CoreEffect>

Process an incoming message, mutate state, return effects.

Trait Implementations§

Source§

impl Default for Core

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Core

§

impl RefUnwindSafe for Core

§

impl Send for Core

§

impl Sync for Core

§

impl Unpin for Core

§

impl UnsafeUnpin for Core

§

impl UnwindSafe for Core

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<State, Message> IntoBoot<State, Message> for State

Source§

fn into_boot(self) -> (State, Task<Message>)

Turns some type into the initial state of some Application.
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeClone for T

Source§

impl<T> MaybeDebug for T

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,