#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.title: Option<String>Document title.
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
impl Metadata
Sourcepub fn new() -> Self
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.
Sourcepub fn with_title(self, value: impl Into<String>) -> Self
pub fn with_title(self, value: impl Into<String>) -> Self
Sets the document title.
Sets the document author.
Sourcepub fn with_subject(self, value: impl Into<String>) -> Self
pub fn with_subject(self, value: impl Into<String>) -> Self
Sets the document subject.
Sourcepub fn with_description(self, value: impl Into<String>) -> Self
pub fn with_description(self, value: impl Into<String>) -> Self
Sets the document description.
Sourcepub fn with_last_saved_by(self, value: impl Into<String>) -> Self
pub fn with_last_saved_by(self, value: impl Into<String>) -> Self
Sets the document last_saved_by.
Sourcepub fn with_keywords<I, S>(self, values: I) -> Self
pub fn with_keywords<I, S>(self, values: I) -> Self
Replaces the document keywords list.
Sourcepub fn with_created(self, value: impl Into<String>) -> Self
pub fn with_created(self, value: impl Into<String>) -> Self
Sets the created timestamp (ISO 8601).
Sourcepub fn with_modified(self, value: impl Into<String>) -> Self
pub fn with_modified(self, value: impl Into<String>) -> Self
Sets the modified timestamp (ISO 8601).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Metadata
Source§impl JsonSchema for Metadata
impl JsonSchema for Metadata
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.