Skip to main content

ActivityContent

Struct ActivityContent 

Source
pub struct ActivityContent {
Show 33 fields pub id: String, pub title: String, pub body: Option<String>, pub progress: Option<f64>, pub progress_segments: Option<Vec<ProgressSegment>>, pub progress_points: Option<Vec<ProgressPoint>>, pub ends_at: Option<u64>, pub icon: Option<String>, pub tint: Option<String>, pub layout: Option<WidgetElement>, pub compact_leading: Option<WidgetElement>, pub compact_trailing: Option<WidgetElement>, pub minimal: Option<WidgetElement>, pub lock_screen: Option<WidgetElement>, pub island_leading: Option<WidgetElement>, pub island_trailing: Option<WidgetElement>, pub island_center: Option<WidgetElement>, pub keyline_tint: Option<String>, pub background_tint: Option<String>, pub sub_text: Option<String>, pub short_critical_text: Option<String>, pub started_at: Option<u64>, pub visibility: Option<String>, pub category: Option<String>, pub actions: Vec<ActivityAction>, pub url: Option<String>, pub stale_at: Option<u64>, pub push: bool, pub template: Option<String>, pub relevance_score: Option<f64>, pub alert: Option<ActivityAlert>, pub timestamp: Option<u64>, pub data: Option<Value>,
}
Expand description

Start or update request for a live activity.

Fields§

§id: String

Your key for this activity (letters, digits, ., _, -). Starting an id that is already running updates it.

§title: String

Main line (notification title on Android). Required unless a template gives it.

§body: Option<String>

Second line.

§progress: Option<f64>

Progress 0..=1.

§progress_segments: Option<Vec<ProgressSegment>>

Android 16 Live Updates ProgressStyle track: relative lengths and colors (one tint segment when omitted). Other platforms draw a plain bar.

§progress_points: Option<Vec<ProgressPoint>>

Android 16 Live Updates ProgressStyle markers along the track.

§ends_at: Option<u64>

Unix ms the countdown runs to (live timer; Android status-bar chip countdown).

§icon: Option<String>

SF Symbol name (mapped to Material / emoji off Apple).

§tint: Option<String>

Accent color (hex) for the icon, progress and Android notification.

§layout: Option<WidgetElement>

Full layout (Lock Screen, expanded Dynamic Island, desktop window).

§compact_leading: Option<WidgetElement>

Dynamic Island compact, leading side.

§compact_trailing: Option<WidgetElement>

Dynamic Island compact, trailing side.

§minimal: Option<WidgetElement>

Dynamic Island minimal (several activities at once).

§lock_screen: Option<WidgetElement>

iOS Lock Screen layout when it should differ from layout (the expanded island).

§island_leading: Option<WidgetElement>

Expanded Dynamic Island, leading region.

§island_trailing: Option<WidgetElement>

Expanded Dynamic Island, trailing region.

§island_center: Option<WidgetElement>

Expanded Dynamic Island, center region (under the camera).

§keyline_tint: Option<String>

Dynamic Island keyline color (hex).

§background_tint: Option<String>

Lock Screen background color (hex) when the layout has none.

§sub_text: Option<String>

Android: small text after the app name (notification sub text).

§short_critical_text: Option<String>

Android 16: short text for the promoted status-bar chip (≤ 7 characters).

§started_at: Option<u64>

Unix ms the activity started: a stopwatch counts up from it (when endsAt is unset).

§visibility: Option<String>

Android lock-screen visibility: public (default), private, secret.

§category: Option<String>

Android notification category (progress default, navigation, transport, workout, status, alarm, service, event).

§actions: Vec<ActivityAction>

Buttons (Android notification actions, at most 3). Taps arrive as widget-action with widgetId = "activity.<id>".

§url: Option<String>

Deep link opened on tap.

§stale_at: Option<u64>

Unix ms after which the OS marks the content outdated (iOS staleDate).

§push: bool

iOS: request an APNs push token (activity-token event, pushToken in the result).

§template: Option<String>

Name of a layout stored with registerActivityTemplate: the device fills it with data ({{data.eta}}, when, repeat, …), so updates carry only data. Fields set on this content override the template’s.

§relevance_score: Option<f64>

iOS: which of several activities the system shows first (higher wins).

§alert: Option<ActivityAlert>

iOS: alert shown with this update (lights the screen, plays sound).

§timestamp: Option<u64>

Unix ms the content was produced: an older update than the shown one is dropped.

§data: Option<Value>

Values for {{data.…}} in the template.

Implementations§

Source§

impl ActivityContent

Source

pub fn validate(&self) -> Result<()>

Reject what no platform can show: empty id or title, bad charset, too many actions, progress out of range, payload over MAX_ACTIVITY_BYTES.

Source

pub fn filled(self) -> Self

The request with layout filled by Self::effective_layout: what every surface receives, so a native renderer never needs its own default.

Source

pub fn effective_layout(&self) -> WidgetElement

layout, or one built from the plain fields: icon + title, body, timer, progress.

Trait Implementations§

Source§

impl Clone for ActivityContent

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 ActivityContent

Source§

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

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

impl Default for ActivityContent

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ActivityContent

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 ActivityContent

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 ActivityContent

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,