pub struct Tree<S> { /* private fields */ }Implementations§
Source§impl<S> Tree<S>
impl<S> Tree<S>
Sourcepub fn open_inferred<P: AsRef<Path>>(
base: P,
scheme: S,
) -> Result<Option<Self>, Error>
pub fn open_inferred<P: AsRef<Path>>( base: P, scheme: S, ) -> Result<Option<Self>, Error>
Open a tree with an inferred prefix part structure and extension constraint.
The result will be empty if and only if the store has no files (even if there are directories).
See the infer_prefix_part_lengths and infer_extension_constraint functions for
important qualifications.
Source§impl<S: Scheme> Tree<S>
impl<S: Scheme> Tree<S>
Sourcepub fn path(&self, name: S::NameRef<'_>) -> Result<PathBuf, String>
pub fn path(&self, name: S::NameRef<'_>) -> Result<PathBuf, String>
Return the path through the tree for the given name, including any fixed extension.
Sourcepub fn open_file(&self, name: S::NameRef<'_>) -> Result<Option<File>, Error>
pub fn open_file(&self, name: S::NameRef<'_>) -> Result<Option<File>, Error>
Try to open a file for reading for the given name, including any fixed extension.
Note that this function will probably not do the right thing for any extension configuration that does not either prohibit extensions or require a fixed extension.
Sourcepub fn create_file(&self, name: S::NameRef<'_>) -> Result<Option<File>, Error>
pub fn create_file(&self, name: S::NameRef<'_>) -> Result<Option<File>, Error>
Try to create a file for writing for the given name, including any fixed extension.
Note that this function will probably not do the right thing for any extension configuration that does not either prohibit extensions or require a fixed extension.
pub fn entries(&self) -> Entries<'_, S> ⓘ
Source§impl Tree<Identity>
impl Tree<Identity>
pub fn builder<P: AsRef<Path>>(base: P) -> TreeBuilder<Identity>
Sourcepub fn infer_prefix_part_lengths<P: AsRef<Path>>(
base: P,
) -> Result<Option<Vec<usize>>, Error>
pub fn infer_prefix_part_lengths<P: AsRef<Path>>( base: P, ) -> Result<Option<Vec<usize>>, Error>
Infer the prefix part lengths used to create a store.
The result will be empty if and only if the store has no files (even if there are directories).
If this function returns a result, it is guaranteed to be correct if the store is valid, but the validity is not checked.
Sourcepub fn infer_extension_constraint<P: AsRef<Path>>(
base: P,
) -> Result<Option<Extension>, Error>
pub fn infer_extension_constraint<P: AsRef<Path>>( base: P, ) -> Result<Option<Extension>, Error>
Infer the extension constraint used to create a store.
The result will be empty if and only if the store has no files (even if there are directories).
This function can only infer the extension constraint if it either prohibits extensions or requires all files to have the same extension.