Skip to main content

DocumentMetadata

Struct DocumentMetadata 

Source
pub struct DocumentMetadata {
Show 18 fields pub title: Option<String>, pub authors: Vec<String>, pub subject: Option<String>, pub description: Option<String>, pub keywords: Vec<String>, pub language: Option<String>, pub publisher: Option<String>, pub identifier: Option<String>, pub rights: Option<String>, pub date: Option<String>, pub created: Option<String>, pub modified: Option<String>, pub last_modified_by: Option<String>, pub creator_tool: Option<String>, pub properties: BTreeMap<String, String>, pub gps: Option<GpsPosition>, pub exif: BTreeMap<String, String>, pub audio: BTreeMap<String, String>,
}
Expand description

The metadata of a document. Every field is optional; a document whose file carries nothing has the default, is_empty. Dates are kept as the file wrote them, normalized to ISO 8601 where the format defines one (Office and ODF dcterms dates, a PDF’s D: dates); EXIF’s own YYYY:MM:DD HH:MM:SS stays as it is in exif and is turned into ISO 8601 for date.

Fields§

§title: Option<String>§authors: Vec<String>§subject: Option<String>§description: Option<String>§keywords: Vec<String>§language: Option<String>§publisher: Option<String>§identifier: Option<String>§rights: Option<String>§date: Option<String>

The document’s own date: an EPUB’s dc:date, a photo’s DateTimeOriginal, an audio file’s date.

§created: Option<String>§modified: Option<String>§last_modified_by: Option<String>§creator_tool: Option<String>

The application that wrote the file (Office’s Application, ODF’s meta:generator, EXIF’s Software, a PDF’s Producer).

§properties: BTreeMap<String, String>

The source’s other named properties, by a lower-case name (revision, category, content_status, company, pages, words, image_size, …).

§gps: Option<GpsPosition>§exif: BTreeMap<String, String>

EXIF tags by their exiftool name, each value as it displays (Make, Model, DateTimeOriginal, ExposureTime, GPSLatitude, …); binary tags (MakerNote, the thumbnail) are left out.

§audio: BTreeMap<String, String>

An audio file’s tags and stream facts by a lower-case name (title, artist, album, genre, track, date, duration, sample_rate, channels, codec, …).

Implementations§

Source§

impl DocumentMetadata

Source

pub fn is_empty(&self) -> bool

Source

pub fn to_json(&self) -> Value

The JSON object the docling JSON export carries as metadata (empty fields left out).

Source

pub fn from_json(value: &Value) -> Self

Read back what to_json wrote (unknown keys are ignored, missing ones default).

Source

pub fn to_front_matter(&self) -> String

The YAML front matter block — ---, one line per present field in a fixed order, --- — or an empty string for empty metadata. Scalars print plain when YAML would read them back as the same string (authors: [Test Author]) and double-quoted otherwise (a date, a number, a colon, a leading symbol), so a front-matter parser gets the strings the file held.

Trait Implementations§

Source§

impl Clone for DocumentMetadata

Source§

fn clone(&self) -> Self

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 Debug for DocumentMetadata

Source§

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

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

impl Default for DocumentMetadata

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DocumentMetadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DocumentMetadata

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for DocumentMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DocumentMetadata

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.