pub struct BaseFiler { /* private fields */ }Expand description
Manages file directories and files for KERI installation resources like databases and configuration files.
Filer instances handle the creation and management of directories and files using configurable paths and permissions to store KERI-specific resources.
Implementations§
Source§impl BaseFiler
impl BaseFiler
Sourcepub fn new<S1, S2>(
name: S1,
base: S2,
temp: bool,
head_dir_path: Option<PathBuf>,
perm: Option<u32>,
reopen: bool,
clear: bool,
reuse: bool,
clean: bool,
filed: bool,
extensioned: bool,
mode: Option<String>,
fext: Option<String>,
defaults: Option<FilerDefaults>,
) -> Result<Self, CoreError>
pub fn new<S1, S2>( name: S1, base: S2, temp: bool, head_dir_path: Option<PathBuf>, perm: Option<u32>, reopen: bool, clear: bool, reuse: bool, clean: bool, filed: bool, extensioned: bool, mode: Option<String>, fext: Option<String>, defaults: Option<FilerDefaults>, ) -> Result<Self, CoreError>
Create a new Filer instance.
§Arguments
name- Unique identifier of file or directorybase- Optional directory path segment inserted before nametemp- If true, open in temporary directory, clear on closehead_dir_path- Optional head directory pathname for main databaseperm- Optional numeric os dir permissions for databasereopen- If true, (re)open with this initclear- If true, remove directory upon close when reopeningreuse- If true, reuse path if already existsclean- If true, path uses clean tail variantfiled- If true, path is file path not directory pathextensioned- When not filed, if true, ensure path ends with fextmode- File open mode when filedfext- File extension when filed or extensioned
§Returns
- Result containing a new Filer instance or an error
Sourcepub fn reopen(
&mut self,
temp: Option<bool>,
head_dir_path: Option<PathBuf>,
perm: Option<u32>,
clear: bool,
reuse: bool,
clean: bool,
mode: Option<String>,
fext: Option<String>,
) -> Result<bool, CoreError>
pub fn reopen( &mut self, temp: Option<bool>, head_dir_path: Option<PathBuf>, perm: Option<u32>, clear: bool, reuse: bool, clean: bool, mode: Option<String>, fext: Option<String>, ) -> Result<bool, CoreError>
Open if closed or close and reopen if opened or create and open if not
§Arguments
temp- If provided, set the temp flaghead_dir_path- If provided, set the head directory pathperm- If provided, set the permissionsclear- If true, remove directory upon closereuse- If true, reuse self.path if already existsclean- If true, path uses clean tail variantmode- If provided, set the file open mode when filedfext- If provided, set the file extension when filed
§Returns
- Result
where true means opened, false means closed
Sourcepub fn remake(
&self,
name: &str,
base: &str,
temp: Option<bool>,
head_dir_path: Option<&Path>,
perm: Option<u32>,
clean: bool,
filed: bool,
extensioned: bool,
mode: Option<&str>,
fext: Option<&str>,
) -> Result<(PathBuf, Option<File>), CoreError>
pub fn remake( &self, name: &str, base: &str, temp: Option<bool>, head_dir_path: Option<&Path>, perm: Option<u32>, clean: bool, filed: bool, extensioned: bool, mode: Option<&str>, fext: Option<&str>, ) -> Result<(PathBuf, Option<File>), CoreError>
Makes and returns (path, file) by opening or creating and opening if not preexistent, directory or file at path
§Arguments
name- Unique name alias portion of pathbase- Optional base inserted before name in pathtemp- Optional temp flag:- None means ignore
- Some(true) means open temporary directory, may clear on close
- Some(false) means open persistent directory, may not clear on close
head_dir_path- Optional head directory pathname of main databaseperm- Directory or file permissionsclean- True means make path for cleaned version and remove old directory or file at clean path if any.filed- True means path is file path not directory pathextensioned- When not filed: True means ensure path ends with fext False means do not ensure path ends with fextmode- File open mode when filed, such as “w+”fext- File extension when filed
§Returns
- Result containing a tuple with (PathBuf, Option
)
Sourcepub fn exists(
&self,
name: &str,
base: &str,
head_dir_path: Option<&Path>,
clean: bool,
filed: bool,
extensioned: bool,
fext: Option<&str>,
) -> Result<bool, CoreError>
pub fn exists( &self, name: &str, base: &str, head_dir_path: Option<&Path>, clean: bool, filed: bool, extensioned: bool, fext: Option<&str>, ) -> Result<bool, CoreError>
Check if (path. file) exists for a given set of parameters for remake. Temp is not allowed.
§Arguments
name- Unique name alias portion of pathbase- Optional base inserted before name in pathhead_dir_path- Optional head directory pathname of main databaseclean- True means make path for cleaned version False means make path normally (not clean)filed- True means path is file path not directory path False means path is directory path not file pathextensioned- When not filed: True means ensure path ends with fext False means do not ensure path ends with fextfext- File extension when filed
§Returns
- Result containing a boolean:
- true means path or alt path exists
- false means neither exists
Sourcepub fn open(&mut self) -> Result<()>
pub fn open(&mut self) -> Result<()>
Opens or creates the directory and/or file specified by this Filer
Sourcepub fn get_file_mut(&mut self) -> Option<&mut File>
pub fn get_file_mut(&mut self) -> Option<&mut File>
Returns a mutable reference to the file if opened
Trait Implementations§
Source§impl Filer for BaseFiler
impl Filer for BaseFiler
fn defaults() -> FilerDefaults
Source§const HEAD_DIR_PATH: &'static str = "/usr/local/var"
const HEAD_DIR_PATH: &'static str = "/usr/local/var"
Default absolute directory path head such as “/usr/local/var”
Source§const TAIL_DIR_PATH: &'static str = "keri"
const TAIL_DIR_PATH: &'static str = "keri"
Default relative directory path tail when using head
Source§const CLEAN_TAIL_DIR_PATH: &'static str = "keri/clean"
const CLEAN_TAIL_DIR_PATH: &'static str = "keri/clean"
Default relative directory path tail when creating clean
Source§const ALT_TAIL_DIR_PATH: &'static str = ".keri"
const ALT_TAIL_DIR_PATH: &'static str = ".keri"
Default alternative relative directory path tail as fallback
Source§const ALT_CLEAN_TAIL_DIR_PATH: &'static str = ".keri/clean"
const ALT_CLEAN_TAIL_DIR_PATH: &'static str = ".keri/clean"
Default alternative relative path tail when creating clean
Source§const TEMP_PREFIX: &'static str = "keri_"
const TEMP_PREFIX: &'static str = "keri_"
Default relative directory path prefix when using temp head
Source§const TEMP_HEAD_DIR: &'static str = "/tmp"
const TEMP_HEAD_DIR: &'static str = "/tmp"
Default relative directory path prefix when using temp head
Auto Trait Implementations§
impl Freeze for BaseFiler
impl RefUnwindSafe for BaseFiler
impl Send for BaseFiler
impl Sync for BaseFiler
impl Unpin for BaseFiler
impl UnsafeUnpin for BaseFiler
impl UnwindSafe for BaseFiler
Blanket Implementations§
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
Mutably borrows from an owned value. Read more