Skip to main content

DirectiveJson

Enum DirectiveJson 

Source
pub enum DirectiveJson {
    Transaction {
        date: String,
        flag: String,
        payee: Option<String>,
        narration: Option<String>,
        tags: Vec<String>,
        links: Vec<String>,
        postings: Vec<PostingJson>,
        meta: HashMap<String, MetaValueJson>,
    },
    Balance {
        date: String,
        account: String,
        amount: AmountValue,
        tolerance: Option<String>,
        meta: HashMap<String, MetaValueJson>,
    },
    Open {
        date: String,
        account: String,
        currencies: Vec<String>,
        booking: Option<String>,
        meta: HashMap<String, MetaValueJson>,
    },
    Close {
        date: String,
        account: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Commodity {
        date: String,
        currency: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Pad {
        date: String,
        account: String,
        source_account: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Event {
        date: String,
        event_type: String,
        value: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Note {
        date: String,
        account: String,
        comment: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Document {
        date: String,
        account: String,
        path: String,
        tags: Vec<String>,
        links: Vec<String>,
        meta: HashMap<String, MetaValueJson>,
    },
    Price {
        date: String,
        currency: String,
        amount: AmountValue,
        meta: HashMap<String, MetaValueJson>,
    },
    Query {
        date: String,
        name: String,
        query_string: String,
        meta: HashMap<String, MetaValueJson>,
    },
    Custom {
        date: String,
        custom_type: String,
        values: Vec<TypedValueJson>,
        meta: HashMap<String, MetaValueJson>,
    },
}
Expand description

A directive in JSON-serializable form.

Each variant corresponds to a Beancount directive type, with fields representing the directive’s data in a JavaScript-friendly format.

All variants carry a meta field with user-defined key/value metadata from the source (issue #1168). Empty metadata serializes as an absent field, so existing consumers continue to see the pre-#1168 shape on directives without explicit metadata.

Variants§

§

Transaction

Transaction directive.

Fields

§date: String
§flag: String
§payee: Option<String>

Optional payee. Mirrors FFI-WASI’s shape: absent on the wire when None (closes #1221).

§narration: Option<String>

Optional narration. Empty narrations are normalized to None in convert.rs so the field is absent on the wire in the empty case – matches FFI-WASI’s pattern (#1221).

§tags: Vec<String>
§links: Vec<String>
§postings: Vec<PostingJson>
§

Balance

Balance assertion.

Fields

§date: String
§account: String
§tolerance: Option<String>

Explicit tolerance from the ~ 0.01 annotation, stringified. Mirrors rustledger_core::Balance::tolerance.

§

Open

Open account.

Fields

§date: String
§account: String
§currencies: Vec<String>
§booking: Option<String>
§

Close

Close account.

Fields

§date: String
§account: String
§

Commodity

Commodity declaration.

Fields

§date: String
§currency: String
§

Pad

Pad directive.

Fields

§date: String
§account: String
§source_account: String
§

Event

Event directive.

Fields

§date: String
§event_type: String
§value: String
§

Note

Note directive.

Fields

§date: String
§account: String
§comment: String
§

Document

Document directive.

Fields

§date: String
§account: String
§path: String
§tags: Vec<String>

Tags attached to the document directive (issue #1144).

§links: Vec<String>

Links attached to the document directive (issue #1144).

§

Price

Price directive.

Fields

§date: String
§currency: String
§

Query

Query directive.

Fields

§date: String
§name: String
§query_string: String
§

Custom

Custom directive.

values carries the positional arguments after the type keyword. Each value is a TypedValueJson tagged union ({type, value}) that preserves the host MetaValue variant tag, so JS consumers can distinguish (for example) a Date from a String from an Account — all of which would otherwise collapse to bare JSON strings under the untagged MetaValueJson shape.

Pre-#1168: values was dropped entirely from the JSON output. Pre-#1207: present but emitted raw via MetaValueJson (lossy). Post-#1207: emitted via TypedValueJson (this variant), mirroring FFI-WASI’s Vec<TypedValue>.

Both values and meta use skip_serializing_if to omit the field when empty (consistent shape: a Custom directive with no positional args and no metadata serializes as {type, date, custom_type}, matching what the TS shape declares via values? / meta?).

Fields

§date: String
§custom_type: String
§values: Vec<TypedValueJson>

Positional values after the custom TYPE keyword. Each entry is a TypedValueJson ({type, value}) — the tagged shape preserves the host MetaValue variant tag so JS consumers can distinguish a Date from a String from an Account (closes #1207). Mirrors FFI-WASI’s Vec<TypedValue> exactly.

Implementations§

Source§

impl DirectiveJson

Source

pub fn meta(&self) -> &HashMap<String, MetaValueJson>

Return the metadata map for this directive, regardless of which variant it is.

Every variant carries a meta field but the per-variant destructure pattern means call sites that want to read meta generically need a 12-arm match. This accessor centralizes that match so callers don’t reimplement it (and so adding a future variant fails compilation here, not at every call site).

Rust-only API: not exposed to JavaScript via #[wasm_bindgen]. JS consumers read directive.meta directly off the serialized object — meta() only serves Rust callers (tests in this crate; downstream Rust crates that consume the WASM-crate types directly).

Trait Implementations§

Source§

impl Clone for DirectiveJson

Source§

fn clone(&self) -> DirectiveJson

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 DirectiveJson

Source§

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

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

impl<'de> Deserialize<'de> for DirectiveJson

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 Serialize for DirectiveJson

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

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more