Skip to main content

ParsedLedger

Struct ParsedLedger 

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

A parsed and validated ledger that caches the parse result.

Use this class when you need to perform multiple operations on the same source without re-parsing each time.

§Example (JavaScript)

const ledger = new ParsedLedger(source);
if (ledger.isValid()) {
    const balances = ledger.query("BALANCES");
    const formatted = ledger.format();
}

Implementations§

Source§

impl ParsedLedger

Source

pub fn new(source: &str) -> Self

Create a new ParsedLedger from source text.

Parses, interpolates, and validates the source. Call isValid() to check for errors.

Source

pub fn is_valid(&self) -> bool

Check if the ledger is valid (no parse or validation errors).

Source

pub fn get_errors(&self) -> Result<JsValue, JsError>

Get all errors (parse + validation).

Source

pub fn get_parse_errors(&self) -> Result<JsValue, JsError>

Get parse errors only.

Source

pub fn get_validation_errors(&self) -> Result<JsValue, JsError>

Get validation errors only.

Source

pub fn get_directives(&self) -> Result<JsValue, JsError>

Get the parsed directives.

Source

pub fn get_options(&self) -> Result<JsValue, JsError>

Get the ledger options.

Source

pub fn directive_count(&self) -> usize

Get the number of directives.

Source

pub fn query(&self, query_str: &str) -> Result<JsValue, JsError>

Run a BQL query on this ledger.

Source

pub fn balances(&self) -> Result<JsValue, JsError>

Get account balances (shorthand for query(“BALANCES”)).

Source

pub fn format(&self) -> Result<JsValue, JsError>

Format the ledger source.

Source

pub fn expand_pads(&self) -> Result<JsValue, JsError>

Expand pad directives.

Source

pub fn run_plugin(&self, plugin_name: &str) -> Result<JsValue, JsError>

Run a native plugin on this ledger.

Source

pub fn get_completions( &self, line: u32, character: u32, ) -> Result<JsValue, JsError>

Get completions at the given position.

Returns context-aware completions for accounts, currencies, directives, etc. Uses cached account/currency/payee data for efficiency.

Source

pub fn get_hover_info( &self, line: u32, character: u32, ) -> Result<JsValue, JsError>

Get hover information at the given position.

Returns documentation for accounts, currencies, and directive keywords.

Source

pub fn get_definition( &self, line: u32, character: u32, ) -> Result<JsValue, JsError>

Get the definition location for the symbol at the given position.

Returns the location of the open or commodity directive for accounts/currencies. Uses cached LineIndex for O(log n) position lookups.

Source

pub fn get_document_symbols(&self) -> Result<JsValue, JsError>

Get all document symbols for the outline view.

Returns a hierarchical list of all directives with their positions. Uses cached LineIndex for O(log n) position lookups.

Source

pub fn get_references( &self, line: u32, character: u32, ) -> Result<JsValue, JsError>

Find all references to the symbol at the given position.

Returns all occurrences of accounts, currencies, or payees in the document. Uses cached data for efficient lookup.

Trait Implementations§

Source§

impl From<ParsedLedger> for JsValue

Source§

fn from(value: ParsedLedger) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for ParsedLedger

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for ParsedLedger

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for ParsedLedger

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<ParsedLedger>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for ParsedLedger

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for ParsedLedger

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for ParsedLedger

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<ParsedLedger>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for ParsedLedger

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<ParsedLedger>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for ParsedLedger

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for ParsedLedger

Source§

impl VectorIntoWasmAbi for ParsedLedger

Source§

impl WasmDescribe for ParsedLedger

Source§

impl WasmDescribeVector for ParsedLedger

Source§

impl SupportsConstructor for ParsedLedger

Source§

impl SupportsInstanceProperty for ParsedLedger

Source§

impl SupportsStaticProperty for ParsedLedger

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> 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> 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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.