pub struct Bijou { /* private fields */ }
Expand description
The main Bijou interface providing low level APIs.
For high level usage, see BijouFs
and [BijouFuse
].
Implementations§
Source§impl Bijou
impl Bijou
Sourcepub fn create(
path: impl AsRef<StdPath>,
password: impl Into<SecretBytes>,
config: Config,
ops_limit: Limit,
mem_limit: Limit,
) -> Result<()>
pub fn create( path: impl AsRef<StdPath>, password: impl Into<SecretBytes>, config: Config, ops_limit: Limit, mem_limit: Limit, ) -> Result<()>
Create a new Bijou.
The path
should either be an empty directory or non-existent.
password
should be convertible to SecretBytes
(e.g.
Vec<u8>
). Otherwise, you may use SecretBytes::move_from
to create a SecretBytes
from a mutable byte slice. This
is to prevent the password from being copied around in memory.
For more details, see SecretBytes
.
Sourcepub fn open(
path: impl Into<StdPathBuf>,
password: impl Into<SecretBytes>,
) -> Result<Self>
pub fn open( path: impl Into<StdPathBuf>, password: impl Into<SecretBytes>, ) -> Result<Self>
Open an existing Bijou.
password
should be convertible to SecretBytes
(e.g.
Vec<u8>
). Otherwise, you may use SecretBytes::move_from
to create a SecretBytes
from a mutable byte slice. This
is to prevent the password from being copied around in memory.
For more details, see SecretBytes
.
Sourcepub fn lookup(&self, parent: FileId, name: &str) -> Result<FileId>
pub fn lookup(&self, parent: FileId, name: &str) -> Result<FileId>
Looks up a file by name.
Returns the inode and its generation.
Sourcepub fn get_meta(&self, file: FileId) -> Result<FileMeta>
pub fn get_meta(&self, file: FileId) -> Result<FileMeta>
Returns the metadata of the given file.
Sourcepub fn make_node(
&self,
parent: FileId,
name: &str,
kind: FileKind,
symlink: Option<String>,
perms: Option<UnixPerms>,
) -> Result<FileMeta>
pub fn make_node( &self, parent: FileId, name: &str, kind: FileKind, symlink: Option<String>, perms: Option<UnixPerms>, ) -> Result<FileMeta>
Creates a new file (or directory, symlink, etc.).
symlink
must not be None
if kind
is FileKind::Symlink
.
Sourcepub fn link(&self, file: FileId, parent: FileId, name: &str) -> Result<FileMeta>
pub fn link(&self, file: FileId, parent: FileId, name: &str) -> Result<FileMeta>
Creates a hard link for the given file.
Sourcepub fn open_file_direct(
&self,
file: FileId,
options: &OpenOptions,
) -> Result<LowLevelFile>
pub fn open_file_direct( &self, file: FileId, options: &OpenOptions, ) -> Result<LowLevelFile>
Opens a file directly.
As its parameters imply, this method does not support creating the file.
See also open_file
.
Sourcepub fn open_file(
&self,
parent: FileId,
name: &str,
options: &OpenOptions,
perms: Option<UnixPerms>,
) -> Result<LowLevelFile>
pub fn open_file( &self, parent: FileId, name: &str, options: &OpenOptions, perms: Option<UnixPerms>, ) -> Result<LowLevelFile>
Opens a file, and creates it if necessary.
See also open_file_direct
.
Sourcepub fn resolve_parent<'a>(
&self,
path: &'a Path,
) -> Result<(FileId, Option<&'a str>)>
pub fn resolve_parent<'a>( &self, path: &'a Path, ) -> Result<(FileId, Option<&'a str>)>
Resolves a path, returning its parent and its name.
If the path is /
, returns (FileId::ROOT, None)
.
Different from resolve
, this method does not require
the path to exist.
Sourcepub fn resolve_parent_nonroot<'a>(
&self,
path: &'a Path,
) -> Result<(FileId, &'a str)>
pub fn resolve_parent_nonroot<'a>( &self, path: &'a Path, ) -> Result<(FileId, &'a str)>
Resolves a path, returning its parent and its name.
Different from resolve_parent
, this will throw an error
if the path is /
.
Sourcepub fn read_dir(&self, id: FileId) -> Result<DirIterator<'_>>
pub fn read_dir(&self, id: FileId) -> Result<DirIterator<'_>>
Returns an iterator of the entries of the given directory.
Note that DirIterator::reset
must be called before
the iterator is used.
The content will only be updated when the iterator is reset.
Before that, the content is a snapshot of the directory
at the time of the last call to DirIterator::reset
.
The results include .
and ..
.
Sourcepub fn unlink(&self, parent: FileId, name: &str) -> Result<Option<FileId>>
pub fn unlink(&self, parent: FileId, name: &str) -> Result<Option<FileId>>
Unlinks a file.
Returns the removed file if it is a file and has no more
hardlinks. Otherwise, returns None
.
Sourcepub fn rename(
&self,
parent: FileId,
name: &str,
new_parent: FileId,
new_name: &str,
) -> Result<Option<FileId>>
pub fn rename( &self, parent: FileId, name: &str, new_parent: FileId, new_name: &str, ) -> Result<Option<FileId>>
Renames a file.
Returns the removed file if it is a file and has no more
hardlinks. Otherwise, returns None
.
Sourcepub fn set_len(&self, file: FileId, len: u64) -> Result<()>
pub fn set_len(&self, file: FileId, len: u64) -> Result<()>
Sets the size of a file.
If len
is larger than the current size, the file will be
extended with zeros. Otherwise, the file will be truncated.
Sourcepub fn set_times(
&self,
file: FileId,
accessed: DateTime<Utc>,
modified: DateTime<Utc>,
) -> Result<()>
pub fn set_times( &self, file: FileId, accessed: DateTime<Utc>, modified: DateTime<Utc>, ) -> Result<()>
Sets atime and mtime of a file.
Sourcepub fn set_perms(
&self,
id: FileId,
mode: Option<u16>,
uid: Option<u32>,
gid: Option<u32>,
) -> Result<()>
pub fn set_perms( &self, id: FileId, mode: Option<u16>, uid: Option<u32>, gid: Option<u32>, ) -> Result<()>
Sets the permissions of a file.
Sourcepub fn set_xattr(&self, id: FileId, name: &str, value: &[u8]) -> Result<()>
pub fn set_xattr(&self, id: FileId, name: &str, value: &[u8]) -> Result<()>
Sets extended attribute (xattr) of a file.
Sourcepub fn get_xattr<R>(
&self,
id: FileId,
name: &str,
cb: impl FnOnce(Result<Option<DBPinnableSlice<'_>>>) -> R,
) -> R
pub fn get_xattr<R>( &self, id: FileId, name: &str, cb: impl FnOnce(Result<Option<DBPinnableSlice<'_>>>) -> R, ) -> R
Returns extended attribute (xattr) of a file.