Skip to main content

Metadata

Struct Metadata 

Source
#[non_exhaustive]
pub struct Metadata { pub title: Option<String>, pub author: Option<String>, pub subject: Option<String>, pub description: Option<String>, pub last_saved_by: Option<String>, pub keywords: Vec<String>, pub created: Option<String>, pub modified: Option<String>, pub extras: BTreeMap<String, String>, }
Expand description

Document metadata: title, author, subject, keywords, timestamps.

All fields are optional. Default returns a fully empty metadata (all None / empty Vec / empty map).

§Design Decisions

Timestamps use Option<String> (ISO 8601) instead of chrono::DateTime. Rationale: chrono adds ~250KB compile weight for two fields that Core never does arithmetic on. Smithy crates parse and validate dates when reading from format-specific sources.

#[non_exhaustive] mirrors the established Core pattern (Control, shape enums, etc.). New fields can be added in future versions without breaking external struct literals — callers must use ..Default::default(). See CLAUDE.md “semver-first” working principle.

extras carries <opf:meta name="X"> entries (HWPX) or PropertySet entries (HWP5) that have not yet been promoted to typed fields. Uses BTreeMap for deterministic ordering so encoder output is byte-stable for round-trip tests. Keys are the wire name= value (e.g. "category"); values are the raw text content.

§Examples

use hwpforge_core::Metadata;

let meta = Metadata::default();
assert!(meta.title.is_none());
assert!(meta.keywords.is_empty());
assert!(meta.extras.is_empty());

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§title: Option<String>

Document title.

§author: Option<String>

Document author (corresponds to HWPX <opf:meta name="creator">).

§subject: Option<String>

Document subject (corresponds to HWPX <opf:meta name="subject">).

§description: Option<String>

Free-form description (corresponds to HWPX <opf:meta name="description">).

Distinct from subject: subject is the canonical “subject” line; description carries longer prose summary text that Hancom stores separately.

§last_saved_by: Option<String>

Last person to save the document (corresponds to HWPX <opf:meta name="lastsaveby">).

Distinct from author: author is the document creator; last_saved_by is the most recent editor. Hancom surfaces this via the $lastsaveby SUMMERY auto-field.

§keywords: Vec<String>

Searchable keywords.

Encoders that target HWPX join with ";" into a single <opf:meta name="keyword"> element (matches Hancom convention).

§created: Option<String>

Creation timestamp in ISO 8601 format (e.g. "2026-02-07T10:30:00Z").

§modified: Option<String>

Last modification timestamp in ISO 8601 format.

§extras: BTreeMap<String, String>

Carry slot for <opf:meta> keys not yet promoted to typed fields. Preserves lossless round-trip when Hancom adds new metadata names that HwpForge has not modeled yet.

Implementations§

Source§

impl Metadata

Source

pub fn new() -> Self

Returns a fresh Metadata with all fields at their default (None / empty). Equivalent to Metadata::default(); provided as a chainable seed for builder-style construction so external crates can populate the #[non_exhaustive] struct without struct-literal syntax.

Source

pub fn with_title(self, value: impl Into<String>) -> Self

Sets the document title.

Source

pub fn with_author(self, value: impl Into<String>) -> Self

Sets the document author.

Source

pub fn with_subject(self, value: impl Into<String>) -> Self

Sets the document subject.

Source

pub fn with_description(self, value: impl Into<String>) -> Self

Sets the document description.

Source

pub fn with_last_saved_by(self, value: impl Into<String>) -> Self

Sets the document last_saved_by.

Source

pub fn with_keywords<I, S>(self, values: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Replaces the document keywords list.

Source

pub fn with_created(self, value: impl Into<String>) -> Self

Sets the created timestamp (ISO 8601).

Source

pub fn with_modified(self, value: impl Into<String>) -> Self

Sets the modified timestamp (ISO 8601).

Source

pub fn with_extra( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Inserts a single <opf:meta> carry entry into extras. Chainable.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

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 Metadata

Source§

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

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

impl Default for Metadata

Source§

fn default() -> Metadata

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

impl<'de> Deserialize<'de> for Metadata

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 Display for Metadata

Source§

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

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

impl Eq for Metadata

Source§

impl JsonSchema for Metadata

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Metadata

Source§

fn eq(&self, other: &Metadata) -> 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 Metadata

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 Metadata

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.