pub struct Payload { /* private fields */ }Expand description
Ordered, comment-preserving payload of a card-yaml block.
Contains the block’s $ entries, user fields, and comments interleaved
in source order. See the module docs for the full design.
Implementations§
Source§impl Payload
impl Payload
Sourcepub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self
pub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self
Build from an IndexMap of user fields. No $ entries, no
comments, no fill markers.
Sourcepub fn from_items(items: Vec<PayloadItem>) -> Self
pub fn from_items(items: Vec<PayloadItem>) -> Self
Build from a pre-computed item list (parser and DTO entry point).
Sourcepub fn items(&self) -> &[PayloadItem]
pub fn items(&self) -> &[PayloadItem]
Ordered iterator over raw items ($ entries, fields, comments).
Sourcepub fn items_mut(&mut self) -> &mut [PayloadItem]
pub fn items_mut(&mut self) -> &mut [PayloadItem]
Mutable access to the raw item list. Callers must preserve the
invariants (at most one Quill/Kind/Id/Ext, no duplicate
field keys, every field name matches [A-Za-z_][A-Za-z0-9_]*) — use
the typed mutators when in doubt.
Sourcepub fn quill(&self) -> Option<&QuillReference>
pub fn quill(&self) -> Option<&QuillReference>
The $quill reference, if declared.
Sourcepub fn ext(&self) -> Option<&JsonMap<String, JsonValue>>
pub fn ext(&self) -> Option<&JsonMap<String, JsonValue>>
The $ext map, if declared. The map is opaque — Quillmark does not
interpret its contents and never emits them into the plate JSON.
Sourcepub fn seed(&self) -> Option<&JsonMap<String, JsonValue>>
pub fn seed(&self) -> Option<&JsonMap<String, JsonValue>>
The raw $seed map (keyed by card-kind), if declared. The seeding
layer interprets it; it never reaches the plate JSON. For a parsed,
per-kind overlay, index this map by kind and pass the entry to
crate::SeedOverlay::from_json.
Sourcepub fn set_quill(&mut self, reference: QuillReference)
pub fn set_quill(&mut self, reference: QuillReference)
Set or replace the $quill entry. Inserts at canonical position
(before any $kind / $id / $ext) when adding. Comments are
untouched.
Sourcepub fn set_kind(&mut self, kind: impl Into<String>)
pub fn set_kind(&mut self, kind: impl Into<String>)
Set or replace the $kind entry. Same insertion rules as
set_quill.
Sourcepub fn set_id(&mut self, id: impl Into<String>)
pub fn set_id(&mut self, id: impl Into<String>)
Set or replace the $id entry. Same insertion rules as
set_quill.
Sourcepub fn set_ext(&mut self, value: JsonMap<String, JsonValue>)
pub fn set_ext(&mut self, value: JsonMap<String, JsonValue>)
Set or replace the $ext entry. Same insertion rules as
set_quill; the canonical position is after
$quill / $kind / $id and before any user field.
Any nested comments previously attached to a replaced $ext
entry are dropped (the new value tree may not contain matching
positions).
Sourcepub fn set_seed(&mut self, value: JsonMap<String, JsonValue>)
pub fn set_seed(&mut self, value: JsonMap<String, JsonValue>)
Set or replace the $seed entry. Inserted at the canonical position
(after $quill / $kind / $id / $ext, before any user field).
Nested comments on a replaced $seed are dropped, like
set_ext.
Sourcepub fn take_ext(&mut self) -> Option<JsonMap<String, JsonValue>>
pub fn take_ext(&mut self) -> Option<JsonMap<String, JsonValue>>
Remove the $ext entry, returning the previous map if any. Any
nested comments attached to the entry are dropped.
Sourcepub fn take_seed(&mut self) -> Option<JsonMap<String, JsonValue>>
pub fn take_seed(&mut self) -> Option<JsonMap<String, JsonValue>>
Remove the $seed entry, returning the previous map if any. Any
nested comments attached to the entry are dropped.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_
Iterator over user (key, &value) pairs. Excludes $ entries and
comments; preserves source order.
Sourcepub fn get(&self, key: &str) -> Option<&QuillValue>
pub fn get(&self, key: &str) -> Option<&QuillValue>
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
true if a user field with this key is present.
Sourcepub fn is_fill(&self, key: &str) -> bool
pub fn is_fill(&self, key: &str) -> bool
true if a user field with this key is marked !must_fill.
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
value: QuillValue,
) -> Option<QuillValue>
pub fn insert( &mut self, key: impl Into<String>, value: QuillValue, ) -> Option<QuillValue>
Insert or update a user field. Always clears the fill marker
(field is no longer a placeholder). Preserves position for existing
keys; appends new keys at the end. $ entries and comments are
untouched. Replacing an existing field discards its
nested_comments because the new value tree may not contain
matching positions.
Sourcepub fn insert_fill(
&mut self,
key: impl Into<String>,
value: QuillValue,
) -> Option<QuillValue>
pub fn insert_fill( &mut self, key: impl Into<String>, value: QuillValue, ) -> Option<QuillValue>
Insert or update a user field and mark it as a !must_fill placeholder.
Preserves position for existing keys; appends new keys at the end.
Replacing an existing field discards its nested_comments.
Sourcepub fn remove(&mut self, key: &str) -> Option<QuillValue>
pub fn remove(&mut self, key: &str) -> Option<QuillValue>
Remove a user field by key, returning its value. Comments and $
entries are untouched.
Sourcepub fn to_index_map(&self) -> IndexMap<String, QuillValue>
pub fn to_index_map(&self) -> IndexMap<String, QuillValue>
Project the user-field portion into an IndexMap<String, QuillValue>.
Comments, fill markers, and $ entries are dropped. Preserves order.