pub struct VdirClient { /* private fields */ }client only.Expand description
Std-blocking Vdir client wrapping a filesystem root.
Implementations§
Source§impl VdirClient
impl VdirClient
Sourcepub fn new(root: impl Into<VdirPath>) -> Self
pub fn new(root: impl Into<VdirPath>) -> Self
Builds a client rooted at root. No filesystem check is
performed at construction time.
Sourcepub fn run<C, T, E>(&self, coroutine: C) -> Result<T, VdirClientError>
pub fn run<C, T, E>(&self, coroutine: C) -> Result<T, VdirClientError>
Drives any standard-shape coroutine (Yield = VdirYield,
Return = Result<Output, Error>) against the local filesystem
until it terminates.
Sourcepub fn create_collection(
&self,
collection: VdirCollection,
) -> Result<(), VdirClientError>
pub fn create_collection( &self, collection: VdirCollection, ) -> Result<(), VdirClientError>
Runs VdirCollectionCreate: creates the collection directory and
writes its metadata files when present.
Sourcepub fn delete_collection(
&self,
path: impl Into<VdirPath>,
) -> Result<(), VdirClientError>
pub fn delete_collection( &self, path: impl Into<VdirPath>, ) -> Result<(), VdirClientError>
Runs VdirCollectionDelete: recursively removes the collection
rooted at path.
Sourcepub fn list_collections(
&self,
) -> Result<BTreeSet<VdirCollection>, VdirClientError>
pub fn list_collections( &self, ) -> Result<BTreeSet<VdirCollection>, VdirClientError>
Runs VdirCollectionList: enumerates every collection directly
under self.root.
Sourcepub fn rename_collection(
&self,
path: impl Into<VdirPath>,
name: impl ToString,
) -> Result<(), VdirClientError>
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).
Sourcepub fn update_collection(
&self,
collection: VdirCollection,
) -> Result<(), VdirClientError>
pub fn update_collection( &self, collection: VdirCollection, ) -> Result<(), VdirClientError>
Runs VdirCollectionUpdate: atomically rewrites the metadata of
collection.
Sourcepub fn locate_item(
&self,
collection: impl Into<VdirPath>,
id: impl ToString,
) -> Result<(VdirPath, VdirItemKind), VdirClientError>
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.
Sourcepub fn get_item(
&self,
collection: impl Into<VdirPath>,
id: impl ToString,
) -> Result<VdirItem, VdirClientError>
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.
Sourcepub fn list_items(
&self,
collection: impl Into<VdirPath>,
) -> Result<BTreeSet<VdirItem>, VdirClientError>
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.
Sourcepub fn store_item(
&self,
collection: impl Into<VdirPath>,
id: Option<String>,
kind: VdirItemKind,
contents: Vec<u8>,
) -> Result<(String, VdirPath), VdirClientError>
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.
Sourcepub fn copy_item(
&self,
source: impl Into<VdirPath>,
target: impl Into<VdirPath>,
id: impl ToString,
) -> Result<(), VdirClientError>
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.
Sourcepub fn move_item(
&self,
source: impl Into<VdirPath>,
target: impl Into<VdirPath>,
id: impl ToString,
) -> Result<(), VdirClientError>
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.
Sourcepub fn delete_item(
&self,
collection: impl Into<VdirPath>,
id: impl ToString,
) -> Result<(), VdirClientError>
pub fn delete_item( &self, collection: impl Into<VdirPath>, id: impl ToString, ) -> Result<(), VdirClientError>
Runs VdirItemDelete: removes item id from collection.