Skip to main content

Entry

Struct Entry 

Source
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>

Source

pub const fn new(ty: EntryType<'a>, key: &'a str) -> Self

Create a new entry

Source

pub const fn entry_type(&self) -> &EntryType<'a>

Get the entry type

Source

pub fn key(&self) -> &str

Get the citation key

Source

pub fn field(&self, name: &str) -> Option<&Field<'a>>

Get a field by name (case-sensitive).

Source

pub fn field_ignore_case(&self, name: &str) -> Option<&Field<'a>>

Get a field by name (case-insensitive).

Source

pub fn get(&self, name: &str) -> Option<&str>

Get a field value by name (case-sensitive) Note: This only returns string literals, not numbers

Source

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

Source

pub fn get_as_string(&self, name: &str) -> Option<String>

Get a field value as a string, converting numbers if necessary (case-sensitive)

Source

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)

Source

pub fn get_any_ignore_case(&self, names: &[&str]) -> Option<&str>

Get the first string-literal field matching any of the names, case-insensitively.

Source

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.

Source

pub fn has_field(&self, name: &str) -> bool

Return true when a field exists, ignoring ASCII case.

Source

pub fn has_any_field(&self, names: &[&str]) -> bool

Return true when any field in names exists, ignoring ASCII case.

Source

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.

Source

pub fn authors(&self) -> Vec<PersonName>

Parse the author field into structured BibTeX names.

Source

pub fn editors(&self) -> Vec<PersonName>

Parse the editor field into structured BibTeX names.

Source

pub fn translators(&self) -> Vec<PersonName>

Parse the translator field into structured BibTeX names.

Source

pub fn date_parts_for( &self, field: &str, ) -> Option<Result<DateParts, DateParseError>>

Parse a specific date-like field into date parts.

Source

pub fn date_parts(&self) -> Option<Result<DateParts, DateParseError>>

Return issued date parts for this entry.

date, issued, eventdate, origdate, and urldate are checked before falling back to year plus an optional month field.

Source

pub fn resource_fields(&self) -> Vec<ResourceField>

Return classified resource and identifier fields in source order.

Source

pub fn fields(&self) -> &[Field<'a>]

Get all fields

Source

pub fn add_field(&mut self, field: Field<'a>)

Add a field

Source

pub fn set(&mut self, name: &'a str, value: Value<'a>)

Set a field value, replacing the first matching field or appending it.

Source

pub fn set_literal(&mut self, name: &'a str, value: &'a str)

Set a field to a string literal.

Source

pub fn remove(&mut self, name: &str) -> Vec<Field<'a>>

Remove all fields whose name matches exactly.

Source

pub fn rename_field(&mut self, old: &str, new: &'a str) -> usize

Rename all fields whose name matches exactly.

Source

pub fn title(&self) -> Option<String>

Return the title field as a string.

Source

pub fn year(&self) -> Option<String>

Return the year field as a string.

Source

pub fn date(&self) -> Option<String>

Return the date field as a string.

Source

pub fn journal(&self) -> Option<String>

Return the journal field, accepting BibLaTeX’s journaltitle alias.

Source

pub fn booktitle(&self) -> Option<String>

Return the book title field as a string.

Source

pub fn url(&self) -> Option<String>

Return the URL field as a string.

Source

pub fn keywords(&self) -> Vec<String>

Return keywords split on commas or semicolons.

Source

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

Source

pub fn is_valid(&self) -> bool

Check whether the entry has the minimal required fields for its type.

Source

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()));
Source

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()));
Source

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).

Source

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).

Source

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");
Source

pub fn into_owned(self) -> Entry<'static>

Convert to owned version

Trait Implementations§

Source§

impl<'a> Clone for Entry<'a>

Source§

fn clone(&self) -> Entry<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Entry<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Entry<'a>

Source§

fn eq(&self, other: &Entry<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,