pub struct Client { /* private fields */ }
Expand description
Blobfs client
Implementations§
source§impl Client
impl Client
sourcepub fn open_from_namespace() -> Result<Self, BlobfsError>
pub fn open_from_namespace() -> Result<Self, BlobfsError>
Returns an client connected to blobfs from the current component’s namespace.
sourcepub fn open_from_namespace_executable() -> Result<Self, BlobfsError>
pub fn open_from_namespace_executable() -> Result<Self, BlobfsError>
Returns a client connected to blobfs from the current component’s namespace with OPEN_RIGHT_READABLE and OPEN_RIGHT_EXECUTABLE.
sourcepub fn open_from_namespace_rwx() -> Result<Self, BlobfsError>
pub fn open_from_namespace_rwx() -> Result<Self, BlobfsError>
Returns a client connected to blobfs from the current component’s namespace with OPEN_RIGHT_READABLE, OPEN_RIGHT_WRITABLE, OPEN_RIGHT_EXECUTABLE.
sourcepub fn new(proxy: DirectoryProxy) -> Self
pub fn new(proxy: DirectoryProxy) -> Self
Returns an client connected to blobfs from the given blobfs root dir.
sourcepub fn new_test() -> (Self, DirectoryRequestStream)
pub fn new_test() -> (Self, DirectoryRequestStream)
Creates a new client backed by the returned request stream. This constructor should not be used outside of tests.
Panics
Panics on error
sourcepub fn new_mock() -> (Self, Mock)
pub fn new_mock() -> (Self, Mock)
Creates a new client backed by the returned mock. This constructor should not be used outside of tests.
Panics
Panics on error
sourcepub fn new_temp_dir_fake() -> (Self, TempDirFake)
pub fn new_temp_dir_fake() -> (Self, TempDirFake)
Creates a new read-only client backed by the returned TempDirFake
.
TempDirFake
is a thin wrapper around a tempfile::TempDir
and therefore does not
replicate many of the important properties of blobfs, including:
- requiring truncate before write
- requiring file names be hashes of contents
This should therefore generally only be used to test read-only clients of blobfs (i.e. tests in which only the test harness itself is writing to blobfs and the code-under-test is only reading from blobfs).
To help enforce this, the DirectoryProxy used to create the Client
is opened with only
OPEN_RIGHT_READABLE.
Requires a RW directory at “/tmp” in the component namespace.
This constructor should not be used outside of tests.
Panics
Panics on error
sourcepub fn forward_open(
&self,
blob: &Hash,
flags: OpenFlags,
server_end: ServerEnd<NodeMarker>
) -> Result<(), Error>
pub fn forward_open( &self, blob: &Hash, flags: OpenFlags, server_end: ServerEnd<NodeMarker> ) -> Result<(), Error>
Forward an open request directly to BlobFs.
sourcepub async fn list_known_blobs(&self) -> Result<HashSet<Hash>, BlobfsError>
pub async fn list_known_blobs(&self) -> Result<HashSet<Hash>, BlobfsError>
Returns the list of known blobs in blobfs.
sourcepub async fn delete_blob(&self, blob: &Hash) -> Result<(), BlobfsError>
pub async fn delete_blob(&self, blob: &Hash) -> Result<(), BlobfsError>
Delete the blob with the given merkle hash.
sourcepub async fn open_blob_for_read(
&self,
blob: &Hash
) -> Result<FileProxy, OpenError>
pub async fn open_blob_for_read( &self, blob: &Hash ) -> Result<FileProxy, OpenError>
Open the blob for reading.
sourcepub fn open_blob_for_read_no_describe(
&self,
blob: &Hash
) -> Result<FileProxy, OpenError>
pub fn open_blob_for_read_no_describe( &self, blob: &Hash ) -> Result<FileProxy, OpenError>
Open the blob for reading. The target is not verified to be any particular type and may not implement the fuchsia.io.File protocol.
sourcepub async fn open_blob_for_write(
&self,
blob: &Hash,
blob_type: BlobType
) -> Result<Blob<NeedsTruncate>, CreateError>
pub async fn open_blob_for_write( &self, blob: &Hash, blob_type: BlobType ) -> Result<Blob<NeedsTruncate>, CreateError>
Open a new blob for write.
sourcepub async fn has_blob(&self, blob: &Hash) -> bool
pub async fn has_blob(&self, blob: &Hash) -> bool
Returns whether blobfs has a blob with the given hash.
sourcepub async fn filter_to_missing_blobs(
&self,
candidates: &HashSet<Hash>
) -> HashSet<Hash>
pub async fn filter_to_missing_blobs( &self, candidates: &HashSet<Hash> ) -> HashSet<Hash>
Determines which of candidate blobs exist and are readable in blobfs, returning the set difference of candidates and readable.
sourcepub async fn sync(&self) -> Result<(), BlobfsError>
pub async fn sync(&self) -> Result<(), BlobfsError>
Call fuchsia.io/Node.Sync on the blobfs directory.