Skip to main content

FieldQueryHelpers

Trait FieldQueryHelpers 

Source
pub trait FieldQueryHelpers {
    // Required methods
    fn fields_matching_pattern(
        &self,
        query: &SubfieldPatternQuery,
    ) -> Vec<&Field>;
    fn fields_matching_value(&self, query: &SubfieldValueQuery) -> Vec<&Field>;
    fn names_in_range(&self, start_tag: &str, end_tag: &str) -> Vec<&Field>;
    fn authors_with_dates(&self) -> Vec<(&str, &str)>;

    // Provided methods
    fn subjects_with_subdivision(&self, code: char, value: &str) -> Vec<&Field> { ... }
    fn isbns_matching(&self, pattern: &str) -> Result<Vec<&Field>, Error> { ... }
    fn subjects_with_note(&self, subdivision: &str) -> Vec<&Field> { ... }
}
Expand description

Extension trait providing convenient helper methods for advanced field queries.

This trait is automatically implemented for all record types, providing domain-specific query patterns built on top of the core field query API.

Required Methods§

Source

fn fields_matching_pattern(&self, query: &SubfieldPatternQuery) -> Vec<&Field>

Get all fields matching a subfield pattern query.

Source

fn fields_matching_value(&self, query: &SubfieldValueQuery) -> Vec<&Field>

Get all fields matching a subfield value query.

Source

fn names_in_range(&self, start_tag: &str, end_tag: &str) -> Vec<&Field>

Find all name fields within a tag range.

Convenience method for finding names in a specific tag range (e.g., 700-711 for added entries).

§Arguments
  • start_tag - Start of tag range (inclusive)
  • end_tag - End of tag range (inclusive)
§Examples
// Find all added entry names (700, 710, 711)
for name in record.names_in_range("700", "711") {
    println!("Name: {:?}", name);
}
Source

fn authors_with_dates(&self) -> Vec<(&str, &str)>

Find all authors and extract their birth/death dates from field 100/700 subfield ‘d’.

Returns tuples of (name, dates) for each author with date information.

§Examples
for (name, dates) in record.authors_with_dates() {
    println!("{}: {}", name, dates);
}

Provided Methods§

Source

fn subjects_with_subdivision(&self, code: char, value: &str) -> Vec<&Field>

Find all subject headings with a specific subdivision subfield and value.

§Arguments
  • code - The subfield code for the subdivision (e.g., ‘x’, ‘y’, ‘z’)
  • value - The subdivision value to match (exact match)
§Examples
// Find all subjects with "History" subdivision
for subject in record.subjects_with_subdivision('x', "History") {
    println!("Subject: {}", subject);
}
Source

fn isbns_matching(&self, pattern: &str) -> Result<Vec<&Field>, Error>

Find all ISBNs matching a regex pattern.

§Arguments
  • pattern - A regex pattern to match ISBN values
§Returns

An iterator of fields (020) with ISBNs matching the pattern, or an error if the pattern is invalid.

§Errors

Returns a regex::Error if the pattern is not a valid regular expression.

§Examples
// Find all ISBNs starting with 978
if let Ok(isbns) = record.isbns_matching(r"^978-.*") {
    for isbn in isbns {
        println!("ISBN: {:?}", isbn);
    }
}
Source

fn subjects_with_note(&self, subdivision: &str) -> Vec<&Field>

Find all subjects with a particular note in subfield ‘x’ (general subdivision).

§Arguments
  • subdivision - The subdivision text to search for (partial match)
§Examples
for subject in record.subjects_with_note("Medieval") {
    println!("Subject: {:?}", subject);
}

Implementors§