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§
Sourcefn fields_matching_pattern(&self, query: &SubfieldPatternQuery) -> Vec<&Field>
fn fields_matching_pattern(&self, query: &SubfieldPatternQuery) -> Vec<&Field>
Get all fields matching a subfield pattern query.
Sourcefn fields_matching_value(&self, query: &SubfieldValueQuery) -> Vec<&Field>
fn fields_matching_value(&self, query: &SubfieldValueQuery) -> Vec<&Field>
Get all fields matching a subfield value query.
Sourcefn names_in_range(&self, start_tag: &str, end_tag: &str) -> Vec<&Field>
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);
}Provided Methods§
Sourcefn subjects_with_subdivision(&self, code: char, value: &str) -> Vec<&Field>
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);
}Sourcefn isbns_matching(&self, pattern: &str) -> Result<Vec<&Field>, Error>
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);
}
}