Struct Bijou

Source
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

Source

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.

Source

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.

Source

pub fn path(&self) -> &StdPath

Returns the local path of this Bijou.

Source

pub fn root(&self) -> Inode

Returns the root inode.

Source

pub fn lookup(&self, parent: FileId, name: &str) -> Result<FileId>

Looks up a file by name.

Returns the inode and its generation.

Source

pub fn get_meta(&self, file: FileId) -> Result<FileMeta>

Returns the metadata of the given file.

Source

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.

Creates a hard link for the given file.

Source

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.

Source

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.

Source

pub fn resolve(&self, path: impl AsRef<Path>) -> Result<FileId>

Resolves a path to a file.

Source

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.

Source

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 /.

Source

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 ...

Unlinks a file.

Returns the removed file if it is a file and has no more hardlinks. Otherwise, returns None.

Source

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.

Source

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.

Reads the target of a symlink.

Source

pub fn set_times( &self, file: FileId, accessed: DateTime<Utc>, modified: DateTime<Utc>, ) -> Result<()>

Sets atime and mtime of a file.

Source

pub fn set_perms( &self, id: FileId, mode: Option<u16>, uid: Option<u32>, gid: Option<u32>, ) -> Result<()>

Sets the permissions of a file.

Source

pub fn set_xattr(&self, id: FileId, name: &str, value: &[u8]) -> Result<()>

Sets extended attribute (xattr) of a file.

Source

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.

Source

pub fn remove_xattr(&self, id: FileId, name: &str) -> Result<()>

Removes extended attribute (xattr) of a file.

Source

pub fn xattrs(&self, id: FileId) -> Result<Vec<String>>

Returns all extended attributes (xattr) of a file.

Auto Trait Implementations§

§

impl Freeze for Bijou

§

impl !RefUnwindSafe for Bijou

§

impl Send for Bijou

§

impl Sync for Bijou

§

impl Unpin for Bijou

§

impl !UnwindSafe for Bijou

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more