Skip to main content

VdirClient

Struct VdirClient 

Source
pub struct VdirClient { /* private fields */ }
Available on crate feature client only.
Expand description

Std-blocking Vdir client wrapping a filesystem root.

Implementations§

Source§

impl VdirClient

Source

pub fn new(root: impl Into<VdirPath>) -> Self

Builds a client rooted at root. No filesystem check is performed at construction time.

Source

pub fn root(&self) -> &VdirPath

Returns the filesystem root this client operates on.

Source

pub fn run<C, T, E>(&self, coroutine: C) -> Result<T, VdirClientError>
where C: VdirCoroutine<Yield = VdirYield, Return = Result<T, E>>, VdirClientError: From<E>,

Drives any standard-shape coroutine (Yield = VdirYield, Return = Result<Output, Error>) against the local filesystem until it terminates.

Source

pub fn create_collection( &self, collection: VdirCollection, ) -> Result<(), VdirClientError>

Runs VdirCollectionCreate: creates the collection directory and writes its metadata files when present.

Source

pub fn delete_collection( &self, path: impl Into<VdirPath>, ) -> Result<(), VdirClientError>

Runs VdirCollectionDelete: recursively removes the collection rooted at path.

Source

pub fn list_collections( &self, ) -> Result<BTreeSet<VdirCollection>, VdirClientError>

Runs VdirCollectionList: enumerates every collection directly under self.root.

Source

pub fn rename_collection( &self, path: impl Into<VdirPath>, name: impl ToString, ) -> Result<(), VdirClientError>

Runs VdirCollectionRename: renames the collection at path to name (keeping the same parent directory).

Source

pub fn update_collection( &self, collection: VdirCollection, ) -> Result<(), VdirClientError>

Runs VdirCollectionUpdate: atomically rewrites the metadata of collection.

Source

pub fn locate_item( &self, collection: impl Into<VdirPath>, id: impl ToString, ) -> Result<(VdirPath, VdirItemKind), VdirClientError>

Runs VdirItemLocate: finds the on-disk path of item id inside collection.

Source

pub fn get_item( &self, collection: impl Into<VdirPath>, id: impl ToString, ) -> Result<VdirItem, VdirClientError>

Runs VdirItemGet: locates item id in collection and reads its contents from disk.

Source

pub fn list_items( &self, collection: impl Into<VdirPath>, ) -> Result<BTreeSet<VdirItem>, VdirClientError>

Runs VdirItemList: scans collection and returns every .vcf/.ics entry, contents included.

Source

pub fn store_item( &self, collection: impl Into<VdirPath>, id: Option<String>, kind: VdirItemKind, contents: Vec<u8>, ) -> Result<(String, VdirPath), VdirClientError>

Runs VdirItemStore: writes contents as a new (or updated) item under collection. Returns the (possibly generated) id and final on-disk path.

When id is None, a fresh UUIDv4 is generated from the system entropy source.

Source

pub fn copy_item( &self, source: impl Into<VdirPath>, target: impl Into<VdirPath>, id: impl ToString, ) -> Result<(), VdirClientError>

Runs VdirItemCopy: copies item id from source into target.

Source

pub fn move_item( &self, source: impl Into<VdirPath>, target: impl Into<VdirPath>, id: impl ToString, ) -> Result<(), VdirClientError>

Runs VdirItemMove: moves item id from source into target.

Source

pub fn delete_item( &self, collection: impl Into<VdirPath>, id: impl ToString, ) -> Result<(), VdirClientError>

Runs VdirItemDelete: removes item id from collection.

Trait Implementations§

Source§

impl Debug for VdirClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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