#[non_exhaustive]pub struct SubfieldPatternQuery {
pub tag: String,
pub subfield_code: char,
pub negate: bool,
/* private fields */
}Expand description
Query for fields with subfield values matching a regex pattern.
This enables finding fields where a specific subfield’s value matches a regular expression pattern.
§Examples
ⓘ
// Find all ISBNs that start with 978
let query = SubfieldPatternQuery::new("020", 'a', "^978-.*");
for field in record.fields_matching_pattern(&query) {
println!("ISBN: {:?}", field);
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tag: StringTag to match
subfield_code: charSubfield code to match
negate: boolIf true, match fields where the subfield does NOT match the pattern
Implementations§
Source§impl SubfieldPatternQuery
impl SubfieldPatternQuery
Sourcepub fn new(
tag: impl Into<String>,
subfield_code: char,
pattern: &str,
) -> Result<Self, Error>
pub fn new( tag: impl Into<String>, subfield_code: char, pattern: &str, ) -> Result<Self, Error>
Create a new subfield pattern query.
§Arguments
tag- The field tag to search insubfield_code- The subfield code to match againstpattern- A regex pattern string
§Returns
Ok(SubfieldPatternQuery) if the pattern is valid regex, or Err if invalid.
§Errors
Returns a regex::Error if the pattern is not a valid regular expression.
§Examples
ⓘ
let query = SubfieldPatternQuery::new("650", 'a', r"^[A-Z]")?;Sourcepub fn negated(
tag: impl Into<String>,
subfield_code: char,
pattern: &str,
) -> Result<Self, Error>
pub fn negated( tag: impl Into<String>, subfield_code: char, pattern: &str, ) -> Result<Self, Error>
Create a negated subfield pattern query.
Matches fields where the subfield exists but does NOT match the pattern.
§Errors
Returns a regex::Error if the pattern is not a valid regular expression.
Trait Implementations§
Source§impl Clone for SubfieldPatternQuery
impl Clone for SubfieldPatternQuery
Source§fn clone(&self) -> SubfieldPatternQuery
fn clone(&self) -> SubfieldPatternQuery
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 moreAuto Trait Implementations§
impl Freeze for SubfieldPatternQuery
impl RefUnwindSafe for SubfieldPatternQuery
impl Send for SubfieldPatternQuery
impl Sync for SubfieldPatternQuery
impl Unpin for SubfieldPatternQuery
impl UnsafeUnpin for SubfieldPatternQuery
impl UnwindSafe for SubfieldPatternQuery
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more