Skip to main content

Payload

Struct Payload 

Source
pub struct Payload { /* private fields */ }
Expand description

Ordered, comment-preserving payload of a card-yaml block: a read view onto card-yaml storage.

Contains the block’s $ entries, user fields, and comments interleaved in source order. See the module docs for the full design.

Mutation is crate-internal. The invariants an edit must hold — at most one $quill / $kind / $ext / $seed, no duplicate field keys, every field name matching [A-Za-z_][A-Za-z0-9_]* — are not all expressible in the mutators’ signatures, so out-of-crate authoring goes through the verbs that do enforce them: Card::store_field / store_ext / store_seed_overlay, Document::set_quill_ref, and TypedWriter.

Implementations§

Source§

impl Payload

Source

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

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

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 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 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 / ext / seed.

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

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

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

Inequality operator !=. Read more
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.