pub struct PatternLine { /* private fields */ }Expand description
Helper struct that permits to transform a template line with patterns into an instantiated line from a match.
Useful when you permit the user to reconstruct lines from an action, like in reaction’s native actions and in the virtual plugin:
actions:
native:
cmd: ["iptables", "...", "<ip>"]
virtual:
type: virtual
options:
send: "<ip>: bad password on user <user>"
to: "my_virtual_stream"Usage example:
let template = "<ip>: bad password on user <user>".to_string();
let patterns = vec!["ip".to_string(), "user".to_string()];
let pattern_line = PatternLine::new(template, patterns);
assert_eq!(
pattern_line.line(vec!["1.2.3.4".to_string(), "root".to_string()]),
"1.2.3.4: bad password on user root".to_string(),
);You can find full examples in those plugins:
reaction-plugin-virtual,
reaction-plugin-cluster.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PatternLine
impl RefUnwindSafe for PatternLine
impl Send for PatternLine
impl Sync for PatternLine
impl Unpin for PatternLine
impl UnwindSafe for PatternLine
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