pub struct Loader { /* private fields */ }Expand description
Beancount file loader.
Implementations§
Source§impl Loader
impl Loader
Sourcepub const fn with_path_security(self, enabled: bool) -> Self
pub const fn with_path_security(self, enabled: bool) -> Self
Enable path traversal protection.
When enabled, include directives cannot escape the root directory of the main beancount file. This prevents malicious ledger files from accessing sensitive files outside the ledger directory.
§Example
let result = Loader::new()
.with_path_security(true)
.load(Path::new("ledger.beancount"))?;Sourcepub fn with_root_dir(self, root: PathBuf) -> Self
pub fn with_root_dir(self, root: PathBuf) -> Self
Set a custom root directory for path security.
By default, the root directory is the parent directory of the main file. This method allows overriding that to a custom directory.
Sourcepub fn load(&mut self, path: &Path) -> Result<LoadResult, LoadError>
pub fn load(&mut self, path: &Path) -> Result<LoadResult, LoadError>
Load a beancount file and all its includes.
Parses the file, processes options and plugin directives, and recursively loads any included files.
§Errors
Returns LoadError in the following cases:
LoadError::Io- Failed to read the file or an included fileLoadError::IncludeCycle- Circular include detected
Note: Parse errors and path traversal errors are collected in
LoadResult::errors rather than returned directly, allowing
partial results to be returned.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Loader
impl RefUnwindSafe for Loader
impl Send for Loader
impl Sync for Loader
impl Unpin for Loader
impl UnwindSafe for Loader
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> 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.