pub struct Action { /* private fields */ }
Expand description

An Action describes a mutation of the global state.

It has a name which is used for pattern matching and a payload. Since gstore is for the GTK framework these actions are linked to GTK Actions. GTK Actions use their own ‘generic value type’ called Variant. Thus gstore Actions have a Variant as argument.

Examples

// given we receive an action `action` in a reducer
// Note: Action::new is not public
let action = Action::new("test".into(), Some(128_i32.to_variant()))
// get a rust value from it by using
if let Some(number) = action.arg::<i32>() {
    // do stuff
}

Implementations

Get the name of the action

Create a new action.

NOTE:

This is a placeholder since rustdoc server can not compile latest gtk yet The actual signature looks like this:

pub fn argument(&self) -> Option<&glib::Variant>

Try to get the argument as . If either there is no argument or the argument is of a different type, the returned Option will be None.

NOTE:

This is a placeholder since rustdoc server can not compile latest gtk yet The actual signature looks like this:

pub fn arg<T: glib::FromVariant + Sized>(&self) -> Option<T>

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.