ActionParams

Trait ActionParams 

Source
pub trait ActionParams: Action {
    // Required method
    fn params(&self) -> String;

    // Provided method
    fn params_pretty(&self) -> String { ... }
}
Expand description

Trait for getting action parameters without the variant name.

Auto-implemented by #[derive(Action)]. Returns just the field values as a string, suitable for display in action logs where the action name is already shown separately.

§Example

#[derive(Action, Clone, Debug)]
enum MyAction {
    SetFilter { query: String, limit: usize },
    Tick,
}

let action = MyAction::SetFilter { query: "foo".into(), limit: 10 };
assert_eq!(action.name(), "SetFilter");
assert_eq!(action.params(), r#"{query: \"foo\", limit: 10}"#);

let tick = MyAction::Tick;
assert_eq!(tick.params(), "");

Required Methods§

Source

fn params(&self) -> String

Get just the action parameters as a string (no variant name)

Provided Methods§

Source

fn params_pretty(&self) -> String

Get a multi-line, detailed representation of the parameters.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§