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
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).
postings: Vec<PostingJson>meta: HashMap<String, MetaValueJson>Balance
Balance assertion.
Fields
amount: AmountValuetolerance: Option<String>Explicit tolerance from the ~ 0.01 annotation, stringified.
Mirrors rustledger_core::Balance::tolerance.
meta: HashMap<String, MetaValueJson>Open
Open account.
Fields
meta: HashMap<String, MetaValueJson>Close
Close account.
Commodity
Commodity declaration.
Pad
Pad directive.
Event
Event directive.
Note
Note directive.
Document
Document directive.
Price
Price directive.
Query
Query directive.
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
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.
meta: HashMap<String, MetaValueJson>Implementations§
Source§impl DirectiveJson
impl DirectiveJson
Sourcepub fn meta(&self) -> &HashMap<String, MetaValueJson>
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
impl Clone for DirectiveJson
Source§fn clone(&self) -> DirectiveJson
fn clone(&self) -> DirectiveJson
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DirectiveJson
impl Debug for DirectiveJson
Source§impl<'de> Deserialize<'de> for DirectiveJson
impl<'de> Deserialize<'de> for DirectiveJson
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>,
Auto Trait Implementations§
impl Freeze for DirectiveJson
impl RefUnwindSafe for DirectiveJson
impl Send for DirectiveJson
impl Sync for DirectiveJson
impl Unpin for DirectiveJson
impl UnsafeUnpin for DirectiveJson
impl UnwindSafe for DirectiveJson
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.