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
impl ParsedLedger
Sourcepub fn new(source: &str) -> Self
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.
Sourcepub fn get_errors(&self) -> Result<JsValue, JsError>
pub fn get_errors(&self) -> Result<JsValue, JsError>
Get all errors (parse + validation).
Sourcepub fn get_parse_errors(&self) -> Result<JsValue, JsError>
pub fn get_parse_errors(&self) -> Result<JsValue, JsError>
Get parse errors only.
Sourcepub fn get_validation_errors(&self) -> Result<JsValue, JsError>
pub fn get_validation_errors(&self) -> Result<JsValue, JsError>
Get validation errors only.
Sourcepub fn get_directives(&self) -> Result<JsValue, JsError>
pub fn get_directives(&self) -> Result<JsValue, JsError>
Get the parsed directives.
Sourcepub fn get_options(&self) -> Result<JsValue, JsError>
pub fn get_options(&self) -> Result<JsValue, JsError>
Get the ledger options.
Sourcepub fn directive_count(&self) -> usize
pub fn directive_count(&self) -> usize
Get the number of directives.
Sourcepub fn query(&self, query_str: &str) -> Result<JsValue, JsError>
pub fn query(&self, query_str: &str) -> Result<JsValue, JsError>
Run a BQL query on this ledger.
Sourcepub fn balances(&self) -> Result<JsValue, JsError>
pub fn balances(&self) -> Result<JsValue, JsError>
Get account balances (shorthand for query(“BALANCES”)).
Sourcepub fn expand_pads(&self) -> Result<JsValue, JsError>
pub fn expand_pads(&self) -> Result<JsValue, JsError>
Expand pad directives.
Sourcepub fn run_plugin(&self, plugin_name: &str) -> Result<JsValue, JsError>
pub fn run_plugin(&self, plugin_name: &str) -> Result<JsValue, JsError>
Run a native plugin on this ledger.
Sourcepub fn get_completions(
&self,
line: u32,
character: u32,
) -> Result<JsValue, JsError>
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.
Sourcepub fn get_hover_info(
&self,
line: u32,
character: u32,
) -> Result<JsValue, JsError>
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.
Sourcepub fn get_definition(
&self,
line: u32,
character: u32,
) -> Result<JsValue, JsError>
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.
Sourcepub fn get_document_symbols(&self) -> Result<JsValue, JsError>
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.
Trait Implementations§
Source§impl From<ParsedLedger> for JsValue
impl From<ParsedLedger> for JsValue
Source§fn from(value: ParsedLedger) -> Self
fn from(value: ParsedLedger) -> Self
Source§impl FromWasmAbi for ParsedLedger
impl FromWasmAbi for ParsedLedger
Source§impl IntoWasmAbi for ParsedLedger
impl IntoWasmAbi for ParsedLedger
Source§impl LongRefFromWasmAbi for ParsedLedger
impl LongRefFromWasmAbi for ParsedLedger
Source§impl OptionFromWasmAbi for ParsedLedger
impl OptionFromWasmAbi for ParsedLedger
Source§impl OptionIntoWasmAbi for ParsedLedger
impl OptionIntoWasmAbi for ParsedLedger
Source§impl RefFromWasmAbi for ParsedLedger
impl RefFromWasmAbi for ParsedLedger
Source§type Anchor = RcRef<ParsedLedger>
type Anchor = RcRef<ParsedLedger>
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§impl RefMutFromWasmAbi for ParsedLedger
impl RefMutFromWasmAbi for ParsedLedger
Source§impl TryFromJsValue for ParsedLedger
impl TryFromJsValue for ParsedLedger
Source§impl VectorFromWasmAbi for ParsedLedger
impl VectorFromWasmAbi for ParsedLedger
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[ParsedLedger]>
Source§impl VectorIntoWasmAbi for ParsedLedger
impl VectorIntoWasmAbi for ParsedLedger
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[ParsedLedger]>) -> Self::Abi
Source§impl WasmDescribeVector for ParsedLedger
impl WasmDescribeVector for ParsedLedger
impl SupportsConstructor for ParsedLedger
impl SupportsInstanceProperty for ParsedLedger
impl SupportsStaticProperty for ParsedLedger
Auto Trait Implementations§
impl Freeze for ParsedLedger
impl RefUnwindSafe for ParsedLedger
impl Send for ParsedLedger
impl Sync for ParsedLedger
impl Unpin for ParsedLedger
impl UnwindSafe for ParsedLedger
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> 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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.