pub struct ActionConfig {
pub stream_name: String,
pub filter_name: String,
pub action_name: String,
pub action_type: String,
pub config: Value,
pub patterns: Vec<String>,
}Expand description
The config for one Stream of a type advertised by this plugin.
For example this user config:
{
streams: {
mystream: {
// ...
filters: {
myfilter: {
// ...
actions: {
myaction: {
type: "myactiontype",
options: {
boolean: true,
array: ["item"],
},
},
},
},
},
},
},
}would result in the following ActionConfig:
ActionConfig {
action_name: "myaction",
action_type: "myactiontype",
config: Value::Object(BTreeMap::from([
("boolean", Value::Boolean(true)),
("array", Value::Array([Value::String("item")])),
])),
}Don’t hesitate to take advantage of serde_json::from_value, to deserialize the Value into a Rust struct:
#[derive(Deserialize)]
struct MyActionOptions {
boolean: bool,
array: Vec<String>,
}
fn validate_config(action_config: Value) -> Result<MyActionOptions, serde_json::Error> {
serde_json::from_value(action_config.into())
}Fields§
§stream_name: String§filter_name: String§action_name: String§action_type: String§config: Value§patterns: Vec<String>Trait Implementations§
Source§impl Clone for ActionConfig
impl Clone for ActionConfig
Source§fn clone(&self) -> ActionConfig
fn clone(&self) -> ActionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'de> Deserialize<'de> for ActionConfig
impl<'de> Deserialize<'de> for ActionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ActionConfig
impl RefUnwindSafe for ActionConfig
impl Send for ActionConfig
impl Sync for ActionConfig
impl Unpin for ActionConfig
impl UnwindSafe for ActionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more