pub struct Grok { /* private fields */ }
Implementations§
Source§impl Grok
impl Grok
Sourcepub fn add_pattern<T: Into<String>>(&mut self, name: T, pattern: T)
pub fn add_pattern<T: Into<String>>(&mut self, name: T, pattern: T)
add a custom pattern, if the pattern is already defined, then it will be overwritten.
§Example
use grok_rs::Grok;
let mut grok = Grok::default();
grok.add_pattern("NAME", r"[A-z0-9._-]+");
Examples found in repository?
More examples
Sourcepub fn compile(
&self,
s: &str,
named_capture_only: bool,
) -> Result<Pattern, String>
pub fn compile( &self, s: &str, named_capture_only: bool, ) -> Result<Pattern, String>
Compile the pattern, and return a Pattern.
- if
named_capture_only
is true, then the unnamed capture group will be ignored. - if the pattern is invalid or not found , then an error will be returned.
Due to the compile process is heavy, it’s recommended compile the pattern once and reuse it.
§Example
the USERNAME will be ignored because named_capture_only
is true.
use grok_rs::Grok;
let grok = Grok::default();
let pattern = grok.compile("%{USERNAME} %{EMAILADDRESS:email}", true).unwrap();
Examples found in repository?
More examples
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grok
impl RefUnwindSafe for Grok
impl Send for Grok
impl Sync for Grok
impl Unpin for Grok
impl UnwindSafe for Grok
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