Struct pica_record::matcher::RecordMatcher
source · pub struct RecordMatcher(/* private fields */);
Expand description
A matcher that matches against a RecordRef.
Implementations§
source§impl RecordMatcher
impl RecordMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new RecordMatcher.
§Errors
This function fails if the given expression is not a valid record matcher.
§Example
use pica_record::matcher::RecordMatcher;
let _matcher = RecordMatcher::new("#003@ > 1")?;
let _matcher = RecordMatcher::new("010@.a == 'ger'")?;
sourcepub fn is_match(&self, record: &RecordRef<'_>, options: &MatcherOptions) -> bool
pub fn is_match(&self, record: &RecordRef<'_>, options: &MatcherOptions) -> bool
Returns true
if the given field(s) matches against the field
matcher.
§Example
use pica_record::matcher::{MatcherOptions, RecordMatcher};
use pica_record::primitives::RecordRef;
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let options = MatcherOptions::default();
let matcher = RecordMatcher::new("002@.0 == 'Tp1'")?;
assert!(matcher.is_match(&record, &options));
Trait Implementations§
source§impl BitAnd for RecordMatcher
impl BitAnd for RecordMatcher
source§fn bitand(self, rhs: Self) -> Self::Output
fn bitand(self, rhs: Self) -> Self::Output
The bitwise AND operator &
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let lhs = RecordMatcher::new("003@.0 == '123456789X'")?;
let rhs = RecordMatcher::new("002@.0 == 'Tp1'")?;
let matcher = lhs & rhs;
assert!(matcher.is_match(&record, &options));
source§type Output = RecordMatcher
type Output = RecordMatcher
The resulting type after applying the
&
operator.source§impl BitAndAssign for RecordMatcher
impl BitAndAssign for RecordMatcher
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
The bitwise AND assignment operator &=
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let mut matcher = RecordMatcher::new("003@.0 == '123456789X'")?;
matcher &= RecordMatcher::new("002@.0 == 'Tp1'")?;
assert!(matcher.is_match(&record, &options));
source§impl BitOr for RecordMatcher
impl BitOr for RecordMatcher
source§fn bitor(self, rhs: Self) -> Self::Output
fn bitor(self, rhs: Self) -> Self::Output
The bitwise OR operator |
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let lhs = RecordMatcher::new("003@.0 == '234567890X'")?;
let rhs = RecordMatcher::new("002@.0 == 'Tp1'")?;
let matcher = lhs | rhs;
assert!(matcher.is_match(&record, &options));
source§type Output = RecordMatcher
type Output = RecordMatcher
The resulting type after applying the
|
operator.source§impl BitOrAssign for RecordMatcher
impl BitOrAssign for RecordMatcher
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
The bitwise OR assignment operator |=
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let mut matcher = RecordMatcher::new("003@.0 == '234567891X'")?;
matcher |= RecordMatcher::new("002@.0 == 'Tp1'")?;
assert!(matcher.is_match(&record, &options));
source§impl BitXor for RecordMatcher
impl BitXor for RecordMatcher
source§fn bitxor(self, rhs: Self) -> Self::Output
fn bitxor(self, rhs: Self) -> Self::Output
The bitwise XOR operator ^
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let lhs = RecordMatcher::new("003@.0 == '123456789X'")?;
let rhs = RecordMatcher::new("002@.0 == 'Tp2'")?;
let matcher = lhs ^ rhs;
assert!(matcher.is_match(&record, &options));
source§type Output = RecordMatcher
type Output = RecordMatcher
The resulting type after applying the
^
operator.source§impl BitXorAssign for RecordMatcher
impl BitXorAssign for RecordMatcher
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
The bitwise XOR assignment operator ^=
of two RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let mut matcher = RecordMatcher::new("003@.0 == '123456789X'")?;
matcher ^= RecordMatcher::new("002@.0 == 'Tp2'")?;
assert!(matcher.is_match(&record, &options));
source§impl Clone for RecordMatcher
impl Clone for RecordMatcher
source§fn clone(&self) -> RecordMatcher
fn clone(&self) -> RecordMatcher
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 RecordMatcher
impl Debug for RecordMatcher
source§impl Display for RecordMatcher
impl Display for RecordMatcher
source§impl Not for RecordMatcher
impl Not for RecordMatcher
source§fn not(self) -> Self::Output
fn not(self) -> Self::Output
The unary logical negation operator !
applied to a
RecordMatcher.
§Example
use pica_record::prelude::*;
use pica_record::primitives::RecordRef;
let options = MatcherOptions::default();
let record = RecordRef::new(vec![
("003@", None, vec![('0', "123456789X")]),
("002@", None, vec![('0', "Tp1")]),
])?;
let matcher = !RecordMatcher::new("002@.0 == 'Tp2'")?;
assert!(matcher.is_match(&record, &options));
source§type Output = RecordMatcher
type Output = RecordMatcher
The resulting type after applying the
!
operator.source§impl PartialEq for RecordMatcher
impl PartialEq for RecordMatcher
impl StructuralPartialEq for RecordMatcher
Auto Trait Implementations§
impl Freeze for RecordMatcher
impl RefUnwindSafe for RecordMatcher
impl Send for RecordMatcher
impl Sync for RecordMatcher
impl Unpin for RecordMatcher
impl UnwindSafe for RecordMatcher
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
)