pub struct Library<'a> { /* private fields */ }Expand description
A parsed BibTeX library.
Implementations§
Source§impl<'a> Library<'a>
impl<'a> Library<'a>
Sourcepub fn parser() -> Parser
pub fn parser() -> Parser
Create a parser with options
§Parallel Processing
The threads option only affects parse_files(). Single file
parsing with parse() is sequential.
§Example
use bibtex_parser::Library;
// Parse multiple files in parallel
let library = Library::parser()
.threads(4)
.parse_files(&["file1.bib", "file2.bib"]).unwrap();
// Single-file parsing stays sequential
let content = "@article{demo, title=\"Demo\"}";
let library = Library::parser()
.threads(4)
.parse(content).unwrap();Sourcepub fn parse(input: &'a str) -> Result<Self>
pub fn parse(input: &'a str) -> Result<Self>
Parse a BibTeX library from a string with default strict settings.
Sourcepub fn parse_file(path: impl AsRef<Path>) -> Result<Library<'static>>
pub fn parse_file(path: impl AsRef<Path>) -> Result<Library<'static>>
Parse a BibTeX library from a file into owned data.
Sourcepub fn write_file(&self, path: impl AsRef<Path>) -> Result<()>
pub fn write_file(&self, path: impl AsRef<Path>) -> Result<()>
Serialize this library to a BibTeX file.
Sourcepub fn entries_mut(&mut self) -> &mut Vec<Entry<'a>>
pub fn entries_mut(&mut self) -> &mut Vec<Entry<'a>>
Get mutable access to all entries
Sourcepub fn strings(&self) -> &[StringDefinition<'a>]
pub fn strings(&self) -> &[StringDefinition<'a>]
Get all string definitions
Sourcepub fn string(&self, name: &str) -> Option<&StringDefinition<'a>>
pub fn string(&self, name: &str) -> Option<&StringDefinition<'a>>
Get a string definition by name.
Sourcepub fn string_value(&self, name: &str) -> Option<&Value<'a>>
pub fn string_value(&self, name: &str) -> Option<&Value<'a>>
Get a string definition value by name.
Sourcepub fn preambles_mut(&mut self) -> &mut Vec<Preamble<'a>>
pub fn preambles_mut(&mut self) -> &mut Vec<Preamble<'a>>
Get mutable access to preambles
Sourcepub fn comments_mut(&mut self) -> &mut Vec<Comment<'a>>
pub fn comments_mut(&mut self) -> &mut Vec<Comment<'a>>
Get mutable access to comments
Sourcepub fn failed_blocks(&self) -> &[FailedBlock<'a>]
pub fn failed_blocks(&self) -> &[FailedBlock<'a>]
Get malformed blocks retained by tolerant parsing.
Sourcepub fn find_by_key(&self, key: &str) -> Option<&Entry<'a>>
pub fn find_by_key(&self, key: &str) -> Option<&Entry<'a>>
Find entries by key
Sourcepub fn find_by_key_ignore_case(&self, key: &str) -> Option<&Entry<'a>>
pub fn find_by_key_ignore_case(&self, key: &str) -> Option<&Entry<'a>>
Find entries by key, ignoring ASCII case.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Return true when the library contains key.
Sourcepub fn find_by_type(&self, ty: &str) -> Vec<&Entry<'a>>
pub fn find_by_type(&self, ty: &str) -> Vec<&Entry<'a>>
Find entries by type
Sourcepub fn find_by_field(&self, field: &str, value: &str) -> Vec<&Entry<'a>>
pub fn find_by_field(&self, field: &str, value: &str) -> Vec<&Entry<'a>>
Find entries by field value
Sourcepub fn find_by_field_ignore_case(
&self,
field: &str,
value: &str,
) -> Vec<&Entry<'a>>
pub fn find_by_field_ignore_case( &self, field: &str, value: &str, ) -> Vec<&Entry<'a>>
Find entries by field value, ignoring ASCII case for the field name and value.
Sourcepub fn find_by_doi(&self, doi: &str) -> Vec<&Entry<'a>>
pub fn find_by_doi(&self, doi: &str) -> Vec<&Entry<'a>>
Find entries whose normalized DOI matches doi.
Sourcepub fn expand_value_ref(&self, value: &Value<'a>) -> Result<Value<'a>>
pub fn expand_value_ref(&self, value: &Value<'a>) -> Result<Value<'a>>
Alternative expansion that works with references (requires cloning for variables)
Sourcepub fn get_expanded_string(&self, value: &Value<'a>) -> Result<String>
pub fn get_expanded_string(&self, value: &Value<'a>) -> Result<String>
Get a fully expanded string value.
Sourcepub fn into_owned(self) -> Library<'static>
pub fn into_owned(self) -> Library<'static>
Convert to owned version (no borrowed data)
Sourcepub fn add_string(&mut self, name: &'a str, value: Value<'a>)
pub fn add_string(&mut self, name: &'a str, value: Value<'a>)
Add a string definition (useful for building libraries programmatically)
Sourcepub fn add_preamble(&mut self, value: Value<'a>)
pub fn add_preamble(&mut self, value: Value<'a>)
Add a preamble
Sourcepub fn add_comment(&mut self, comment: &'a str)
pub fn add_comment(&mut self, comment: &'a str)
Add a comment
Sourcepub fn resolve_strings(&mut self) -> Result<()>
pub fn resolve_strings(&mut self) -> Result<()>
Resolve string variables and concatenations in entries and preambles in place.
Sourcepub fn normalize_doi_fields(&mut self)
pub fn normalize_doi_fields(&mut self)
Normalize DOI fields to lowercase 10.x/... form when recognizable.
Sourcepub fn normalize_months(&mut self, style: MonthStyle)
pub fn normalize_months(&mut self, style: MonthStyle)
Normalize month fields to a chosen representation.
Sourcepub fn normalize_fields(&mut self, options: FieldNormalizeOptions)
pub fn normalize_fields(&mut self, options: FieldNormalizeOptions)
Normalize field names and common BibLaTeX aliases.
Sourcepub fn sort(&mut self, options: SortOptions)
pub fn sort(&mut self, options: SortOptions)
Sort entries and/or fields in place.
Sourcepub fn validate(
&self,
level: ValidationLevel,
) -> Vec<(usize, &Entry<'a>, Vec<ValidationError>)>
pub fn validate( &self, level: ValidationLevel, ) -> Vec<(usize, &Entry<'a>, Vec<ValidationError>)>
Validate all entries in the library Returns a list of entries with their indices and validation errors
Sourcepub fn find_duplicate_keys(&self) -> Vec<&str>
pub fn find_duplicate_keys(&self) -> Vec<&str>
Check for duplicate citation keys Returns a list of duplicate keys (each key appears once in the list even if it has multiple duplicates)
Sourcepub fn find_duplicate_keys_ignore_case(&self) -> Vec<String>
pub fn find_duplicate_keys_ignore_case(&self) -> Vec<String>
Check for duplicate citation keys, ignoring ASCII case.
Sourcepub fn find_duplicate_dois(&self) -> Vec<(String, Vec<&Entry<'a>>)>
pub fn find_duplicate_dois(&self) -> Vec<(String, Vec<&Entry<'a>>)>
Find duplicate DOI groups using normalized DOI values.
Sourcepub fn validate_comprehensive(
&self,
level: ValidationLevel,
) -> ValidationReport<'_>
pub fn validate_comprehensive( &self, level: ValidationLevel, ) -> ValidationReport<'_>
Validate all entries and return a comprehensive validation report
Sourcepub fn stats(&self) -> LibraryStats
pub fn stats(&self) -> LibraryStats
Get statistics about the library
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Library<'a>
impl<'a> RefUnwindSafe for Library<'a>
impl<'a> Send for Library<'a>
impl<'a> Sync for Library<'a>
impl<'a> Unpin for Library<'a>
impl<'a> UnsafeUnpin for Library<'a>
impl<'a> UnwindSafe for Library<'a>
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
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>
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>
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