Enum pica_record::matcher::TagMatcher
source · pub enum TagMatcher {
Tag(Tag),
Pattern([Vec<u8>; 4], String),
}
Expand description
A matcher that matches against a TagRef.
Variants§
Implementations§
source§impl TagMatcher
impl TagMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new TagMatcher.
§Errors
This function fails if the given expression is not a valid tag matcher.
§Example
use pica_record::matcher::TagMatcher;
let _matcher = TagMatcher::new("041[A@]")?;
let _matcher = TagMatcher::new("003@")?;
let _matcher = TagMatcher::new("00.@")?;
sourcepub fn is_match(&self, tag: &TagRef<'_>) -> bool
pub fn is_match(&self, tag: &TagRef<'_>) -> bool
Returns true
if the given tag matches against the matcher.
§Example
use pica_record::matcher::TagMatcher;
use pica_record::primitives::TagRef;
let matcher = TagMatcher::new("00[3-5]@")?;
assert!(!matcher.is_match(&TagRef::new("002@")?));
assert!(matcher.is_match(&TagRef::new("003@")?));
Trait Implementations§
source§impl Clone for TagMatcher
impl Clone for TagMatcher
source§fn clone(&self) -> TagMatcher
fn clone(&self) -> TagMatcher
Returns a copy 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 Debug for TagMatcher
impl Debug for TagMatcher
source§impl Display for TagMatcher
impl Display for TagMatcher
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the tag matcher as a human-readable string.
§Example
use pica_record::matcher::TagMatcher;
let matcher = TagMatcher::new("00[3-5]@")?;
assert_eq!(matcher.to_string(), "00[3-5]@");
let matcher = TagMatcher::new("003@")?;
assert_eq!(matcher.to_string(), "003@");
source§impl PartialEq for TagMatcher
impl PartialEq for TagMatcher
impl StructuralPartialEq for TagMatcher
Auto Trait Implementations§
impl Freeze for TagMatcher
impl RefUnwindSafe for TagMatcher
impl Send for TagMatcher
impl Sync for TagMatcher
impl Unpin for TagMatcher
impl UnwindSafe for TagMatcher
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)