Skip to main content

WidgetConfig

Struct WidgetConfig 

Source
pub struct WidgetConfig {
Show 15 fields pub version: u32, pub small: Option<WidgetElement>, pub medium: Option<WidgetElement>, pub large: Option<WidgetElement>, pub accessory: Option<WidgetElement>, pub entries: Vec<WidgetEntry>, pub strings: BTreeMap<String, BTreeMap<String, String>>, pub default_locale: Option<String>, pub source: Option<DataSource>, pub data: Option<Value>, pub state: Option<Map<String, Value>>, pub transition: Option<Transition>, pub templates: BTreeMap<String, WidgetElement>, pub requires: Option<Requires>, pub fallback: Option<FallbackLayouts>,
}
Expand description

Top-level widget config with layouts per size family.

Fields§

§version: u32

Schema version. Defaults to 1.

§small: Option<WidgetElement>

Layout for the small size family.

§medium: Option<WidgetElement>

Layout for the medium size family.

§large: Option<WidgetElement>

Layout for the large size family.

§accessory: Option<WidgetElement>

iOS / watchOS Lock Screen accessory families (circular, rectangular, inline). Falls back to small. Ignored elsewhere. Not a resolve family: {{…}}, when, repeat and entries do not apply to it.

§entries: Vec<WidgetEntry>

Scheduled states: from at on, an entry’s layouts replace the base ones. The OS switches them while the app is closed (WidgetKit timeline, Android alarm, desktop timer). See crate::resolve.

§strings: BTreeMap<String, BTreeMap<String, String>>

Localized strings per locale ("en", "pt-BR"), used as {{t.key}} in any text.

§default_locale: Option<String>

Locale used when the device locale has no strings table. Default: first table.

§source: Option<DataSource>

JSON the widget fetches by itself on a schedule; its fields are {{data.path}}.

§data: Option<Value>

Default values for {{data.path}} (overridden by setWidgetData and source).

§state: Option<Map<String, Value>>

Defaults of the widget’s local state, read as {{state.key}} / when / bind / repeat.each: "state.list". Taps on elements with set change it in-process (no app needed); setWidgetState changes it from the app. The stored state (state:{widgetId}, state:{widgetId}#{instance}) is merged over these per top-level key.

§transition: Option<Transition>

How content changes between timeline entries / redraws (a hint): numeric animates digits, opacity cross-fades, slide pushes from the bottom. Apple and desktop animate; Android and Adaptive Cards ignore it.

§templates: BTreeMap<String, WidgetElement>

Reusable elements expanded by {"type": "use", "template": "<key>"}.

§requires: Option<Requires>

Minimum renderer contract; older renderers show fallback instead.

§fallback: Option<FallbackLayouts>

Layouts shown by renderers that do not meet requires.

Implementations§

Source§

impl WidgetConfig

Source

pub fn small(el: impl Into<WidgetElement>) -> Self

Config with only the small size family set.

Source

pub fn layouts_mut(&mut self) -> impl Iterator<Item = &mut WidgetElement>

Every layout root, scheduled entries included (for host-side passes such as normalization and image prefetch).

Source

pub fn with_medium(self, el: impl Into<WidgetElement>) -> Self

Set the medium size family.

Source

pub fn with_large(self, el: impl Into<WidgetElement>) -> Self

Set the large size family.

Trait Implementations§

Source§

impl Clone for WidgetConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WidgetConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WidgetConfig

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for WidgetConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for WidgetConfig

Available on crate feature schema only.
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for WidgetConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'de, D, R> CommandArg<'de, R> for D
where D: Deserialize<'de>, R: Runtime,

Source§

fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>

Derives an instance of Self from the CommandItem. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> IpcResponse for T
where T: Serialize,

Source§

fn body(self) -> Result<InvokeResponseBody, Error>

Resolve the IPC response body.
Source§

impl<T> ScopeObject for T
where T: Send + Sync + Debug + DeserializeOwned + 'static,

Source§

type Error = Error

The error type.
Source§

fn deserialize<R>( _app: &AppHandle<R>, raw: Value, ) -> Result<T, <T as ScopeObject>::Error>
where R: Runtime,

Deserialize the raw scope value.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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> UserEvent for T
where T: Debug + Clone + Send + 'static,