Skip to main content

Payload

Struct Payload 

Source
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

Source

pub fn new() -> Self

Create an empty Payload.

Source

pub fn from_index_map(map: IndexMap<String, QuillValue>) -> Self

Build from an IndexMap of user fields. No $ entries, no comments, no fill markers.

Source

pub fn from_items(items: Vec<PayloadItem>) -> Self

Build from a pre-computed item list (parser and DTO entry point).

Source

pub fn items(&self) -> &[PayloadItem]

Ordered iterator over raw items ($ entries, fields, comments).

Source

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.

Source

pub fn quill(&self) -> Option<&QuillReference>

The $quill reference, if declared.

Source

pub fn kind(&self) -> Option<&str>

The $kind value, if declared.

Source

pub fn id(&self) -> Option<&str>

The $id value, if declared.

Source

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.

Source

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.

Source

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.

Source

pub fn set_kind(&mut self, kind: impl Into<String>)

Set or replace the $kind entry. Same insertion rules as set_quill.

Source

pub fn set_id(&mut self, id: impl Into<String>)

Set or replace the $id entry. Same insertion rules as set_quill.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &QuillValue)> + '_

Iterator over user (key, &value) pairs. Excludes $ entries and comments; preserves source order.

Source

pub fn keys(&self) -> impl Iterator<Item = &String> + '_

Iterator over user field keys.

Source

pub fn len(&self) -> usize

Number of user-field items ($ entries and comments excluded).

Source

pub fn is_empty(&self) -> bool

true when there are no user-field items.

Source

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

Look up a user-field value by key. $ entries are not visible via this accessor — use quill / kind / id.

Source

pub fn contains_key(&self, key: &str) -> bool

true if a user field with this key is present.

Source

pub fn is_fill(&self, key: &str) -> bool

true if a user field with this key is marked !must_fill.

Source

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.

Source

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.

Source

pub fn remove(&mut self, key: &str) -> Option<QuillValue>

Remove a user field by key, returning its value. Comments and $ entries are untouched.

Source

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.

Trait Implementations§

Source§

impl Clone for Payload

Source§

fn clone(&self) -> Payload

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 Payload

Source§

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

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

impl Default for Payload

Source§

fn default() -> Payload

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

impl From<&Payload> for PayloadV0_92_0

Source§

fn from(payload: &Payload) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a Payload

Source§

type Item = (&'a String, &'a QuillValue)

The type of the elements being iterated over.
Source§

type IntoIter = FilterMap<Iter<'a, PayloadItem>, fn(&'a PayloadItem) -> Option<(&'a String, &'a QuillValue)>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Payload

Source§

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

Source§

impl TryFrom<PayloadV0_92_0> for Payload

Source§

type Error = StorageError

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

fn try_from(p: PayloadV0_92_0) -> Result<Self, Self::Error>

Performs the conversion.

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