Skip to main content

Crate rustledger_wasm

Crate rustledger_wasm 

Source
Expand description

Beancount WASM Bindings.

This crate provides WebAssembly bindings for using Beancount from JavaScript/TypeScript.

§Features

  • Parse Beancount files (single and multi-file with includes)
  • Validate ledgers
  • Run BQL queries
  • Format directives
  • ParsedLedger — cached single-file with editor features (completions, hover, etc.)
  • Ledger — cached multi-file with queries and cross-file completions

§Example (JavaScript)

import init, { parse, validateSource, query } from '@rustledger/wasm';

await init();

const source = `
2024-01-01 open Assets:Bank USD
2024-01-15 * "Coffee"
  Expenses:Food  5.00 USD
  Assets:Bank   -5.00 USD
`;

const result = parse(source);
if (result.errors.length === 0) {
    const validation = validateSource(source);
    console.log('Validation errors:', validation.errors);
}

Modules§

convert
Conversion functions between Beancount types and JSON DTOs.
types
Data transfer objects for WASM serialization.

Structs§

Ledger
A fully processed multi-file ledger for queries and validation.
ParsedLedger
A parsed and validated single-file ledger with editor features.

Functions§

balances
Calculate account balances.
bql_completions
Get BQL query completions at cursor position.
expand_pads
Process pad directives and expand them.
format
Format a Beancount source string.
hash_sources
Compute a SHA-256 fingerprint of one or more source strings.
init
Initialize the WASM module.
list_plugins
List available native plugins.
parse
Parse a Beancount source string.
parse_multi_file
Parse multiple Beancount files with include resolution.
query
Run a BQL query on a Beancount source string.
query_multi_file
Run a BQL query on multiple Beancount files.
run_plugin
Run a single named plugin against a Beancount source and return the resulting directives as JSON.
validate_multi_file
Validate multiple Beancount files with include resolution.
validate_source
Validate a Beancount source string.
version
Get version information.