pub struct Entry<'a> {
pub ty: EntryType<'a>,
pub key: Cow<'a, str>,
pub fields: Vec<Field<'a>>,
}Expand description
A BibTeX entry (article, book, etc.)
Fields§
§ty: EntryType<'a>Entry type (article, book, inproceedings, etc.)
key: Cow<'a, str>Citation key
fields: Vec<Field<'a>>Fields (author, title, year, etc.)
Implementations§
Source§impl<'a> Entry<'a>
impl<'a> Entry<'a>
Sourcepub const fn entry_type(&self) -> &EntryType<'a>
pub const fn entry_type(&self) -> &EntryType<'a>
Get the entry type
Sourcepub fn field_ignore_case(&self, name: &str) -> Option<&Field<'a>>
pub fn field_ignore_case(&self, name: &str) -> Option<&Field<'a>>
Get a field by name (case-insensitive).
Sourcepub fn get(&self, name: &str) -> Option<&str>
pub fn get(&self, name: &str) -> Option<&str>
Get a field value by name (case-sensitive) Note: This only returns string literals, not numbers
Sourcepub fn get_ignore_case(&self, name: &str) -> Option<&str>
pub fn get_ignore_case(&self, name: &str) -> Option<&str>
Get a field value by name (case-insensitive) Returns the first field whose name matches ignoring case Note: This only returns string literals, not numbers
Sourcepub fn get_as_string(&self, name: &str) -> Option<String>
pub fn get_as_string(&self, name: &str) -> Option<String>
Get a field value as a string, converting numbers if necessary (case-sensitive)
Sourcepub fn get_as_string_ignore_case(&self, name: &str) -> Option<String>
pub fn get_as_string_ignore_case(&self, name: &str) -> Option<String>
Get a field value as a string, converting numbers if necessary (case-insensitive)
Sourcepub fn get_any_ignore_case(&self, names: &[&str]) -> Option<&str>
pub fn get_any_ignore_case(&self, names: &[&str]) -> Option<&str>
Get the first string-literal field matching any of the names, case-insensitively.
Sourcepub fn get_any_as_string_ignore_case(&self, names: &[&str]) -> Option<String>
pub fn get_any_as_string_ignore_case(&self, names: &[&str]) -> Option<String>
Get the first field matching any of the names as a string, case-insensitively.
Sourcepub fn has_field(&self, name: &str) -> bool
pub fn has_field(&self, name: &str) -> bool
Return true when a field exists, ignoring ASCII case.
Sourcepub fn has_any_field(&self, names: &[&str]) -> bool
pub fn has_any_field(&self, names: &[&str]) -> bool
Return true when any field in names exists, ignoring ASCII case.
Sourcepub fn doi(&self) -> Option<String>
pub fn doi(&self) -> Option<String>
Return the normalized DOI, if the entry has a recognizable DOI field.
This accepts common input forms such as 10.1000/xyz,
doi:10.1000/xyz, and https://doi.org/10.1000/xyz.
Parse the author field into structured BibTeX names.
Sourcepub fn editors(&self) -> Vec<PersonName>
pub fn editors(&self) -> Vec<PersonName>
Parse the editor field into structured BibTeX names.
Sourcepub fn set(&mut self, name: &'a str, value: Value<'a>)
pub fn set(&mut self, name: &'a str, value: Value<'a>)
Set a field value, replacing the first matching field or appending it.
Sourcepub fn set_literal(&mut self, name: &'a str, value: &'a str)
pub fn set_literal(&mut self, name: &'a str, value: &'a str)
Set a field to a string literal.
Sourcepub fn remove(&mut self, name: &str) -> Vec<Field<'a>>
pub fn remove(&mut self, name: &str) -> Vec<Field<'a>>
Remove all fields whose name matches exactly.
Sourcepub fn rename_field(&mut self, old: &str, new: &'a str) -> usize
pub fn rename_field(&mut self, old: &str, new: &'a str) -> usize
Rename all fields whose name matches exactly.
Sourcepub fn journal(&self) -> Option<String>
pub fn journal(&self) -> Option<String>
Return the journal field, accepting BibLaTeX’s journaltitle alias.
Sourcepub fn validate(
&self,
level: ValidationLevel,
) -> Result<(), Vec<ValidationError>>
pub fn validate( &self, level: ValidationLevel, ) -> Result<(), Vec<ValidationError>>
Validate the entry according to the specified level Returns Ok(()) if valid, or Err with a list of validation errors
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if entry has all required fields for its type (backward compatible)
Sourcepub fn get_unicode(&self, name: &str) -> Option<String>
pub fn get_unicode(&self, name: &str) -> Option<String>
Get a field value with LaTeX sequences converted to Unicode (case-sensitive)
This method converts common LaTeX escape sequences like \'e to é and \"{o} to ö.
Returns None if the field doesn’t exist or isn’t a string literal.
§Examples
let bibtex = r#"@article{test, author = "Jos\'e Garc\'ia"}"#;
let library = Library::parser().parse(bibtex).unwrap();
let entry = &library.entries()[0];
assert_eq!(entry.get_unicode("author"), Some("José García".to_string()));Sourcepub fn get_unicode_ignore_case(&self, name: &str) -> Option<String>
pub fn get_unicode_ignore_case(&self, name: &str) -> Option<String>
Get a field value with LaTeX sequences converted to Unicode (case-insensitive)
This method converts common LaTeX escape sequences like \'e to é and \"{o} to ö.
Returns None if the field doesn’t exist or isn’t a string literal.
Field name matching is case-insensitive.
§Examples
let bibtex = r#"@article{test, TITLE = "M\\\"uller's work"}"#;
let library = Library::parser().parse(bibtex).unwrap();
let entry = &library.entries()[0];
assert_eq!(entry.get_unicode_ignore_case("title"), Some("Müller's work".to_string()));Sourcepub fn get_as_unicode_string(&self, name: &str) -> Option<String>
pub fn get_as_unicode_string(&self, name: &str) -> Option<String>
Get a field value as string with LaTeX conversion (case-sensitive)
Similar to get_as_string() but converts LaTeX sequences to Unicode.
This handles all field types (literals, numbers, variables, concatenations).
Sourcepub fn get_as_unicode_string_ignore_case(&self, name: &str) -> Option<String>
pub fn get_as_unicode_string_ignore_case(&self, name: &str) -> Option<String>
Get a field value as string with LaTeX conversion (case-insensitive)
Similar to get_as_string_ignore_case() but converts LaTeX sequences to Unicode.
This handles all field types (literals, numbers, variables, concatenations).
Sourcepub fn fields_unicode(&self) -> Vec<(String, String)>
pub fn fields_unicode(&self) -> Vec<(String, String)>
Get all fields with LaTeX converted to Unicode
Returns a vector of (field_name, unicode_value) pairs for all string literal fields.
Non-string fields (numbers, variables) are excluded.
§Examples
let bibtex = r#"@article{test,
author = "Jos\'e Garc\'ia",
title = "\\alpha and \\beta particles",
year = 2024
}"#;
let library = Library::parser().parse(bibtex).unwrap();
let entry = &library.entries()[0];
let unicode_fields = entry.fields_unicode();
let author = unicode_fields.iter()
.find(|(k, _)| k == "author")
.map(|(_, v)| v.as_str())
.unwrap();
assert_eq!(author, "José García");Sourcepub fn into_owned(self) -> Entry<'static>
pub fn into_owned(self) -> Entry<'static>
Convert to owned version
Trait Implementations§
impl<'a> StructuralPartialEq for Entry<'a>
Auto Trait Implementations§
impl<'a> Freeze for Entry<'a>
impl<'a> RefUnwindSafe for Entry<'a>
impl<'a> Send for Entry<'a>
impl<'a> Sync for Entry<'a>
impl<'a> Unpin for Entry<'a>
impl<'a> UnsafeUnpin for Entry<'a>
impl<'a> UnwindSafe for Entry<'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