pub trait SyncIo:
Send
+ Sync
+ Sized
+ 'static {
type Directory: SyncIoDirectory;
Show 25 methods
// Required methods
fn attr_get(
&self,
query: NodeAttributesQuery,
) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>;
fn attr_set(&self, attributes: MutableNodeAttributes) -> Result<(), Status>;
fn query_filesystem(&self) -> Result<FilesystemInfo, Status>;
fn open<F: Factory<Self>>(
&self,
path: &str,
flags: Flags,
create_attributes: Option<MutableNodeAttributes>,
query: NodeAttributesQuery,
factory: F,
) -> Result<F::Result, Status>;
fn open_pipelined<F: Factory<Self>>(
&self,
paths: &[&str],
flags: Flags,
query: NodeAttributesQuery,
factory_fn: impl FnMut() -> F,
) -> impl Iterator<Item = Result<F::Result, Status>>;
fn link_into(&self, target_dir: &Self, name: &str) -> Result<(), Status>;
fn unlink(&self, name: &str, flags: UnlinkFlags) -> Result<(), Status>;
fn rename(
&self,
old_path: &str,
new_directory: &Self,
new_path: &str,
) -> Result<(), Status>;
fn create_symlink(&self, name: &str, target: &[u8]) -> Result<Self, Status>;
fn read_partial(
&self,
offset: u64,
max: usize,
) -> Result<(Vec<u8>, bool), Status>;
fn write(&self, offset: u64, data: &[u8]) -> Result<usize, Status>;
fn supports_vectored(&self) -> bool;
unsafe fn readv(
&self,
offset: u64,
iovecs: &mut [zx_iovec_t],
) -> Result<usize, Status>;
fn writev(
&self,
offset: u64,
iovecs: &[zx_iovec_t],
) -> Result<usize, Status>;
fn truncate(&self, length: u64) -> Result<(), Status>;
fn vmo_get(&self, flags: VmarFlags) -> Result<Vmo, Status>;
fn sync(&self) -> Result<(), Status>;
fn enable_verity(
&self,
descriptor: &zxio_fsverity_descriptor_t,
) -> Result<(), Status>;
fn allocate(
&self,
offset: u64,
len: u64,
mode: AllocateMode,
) -> Result<(), Status>;
fn xattr_get(&self, name: &[u8]) -> Result<Vec<u8>, Status>;
fn xattr_set(
&self,
name: &[u8],
value: &[u8],
mode: XattrSetMode,
) -> Result<(), Status>;
fn xattr_remove(&self, name: &[u8]) -> Result<(), Status>;
fn xattr_list(&self) -> Result<Vec<Vec<u8>>, Status>;
fn open_directory(&self) -> Result<Self::Directory, Status>;
// Provided method
fn read<E>(
&self,
offset: u64,
len: usize,
callback: impl FnMut(Vec<u8>) -> Result<usize, E>,
map_err: impl FnOnce(Status) -> E,
) -> Result<usize, E> { ... }
}Expand description
Trait abstraction for synchronous I/O operations on Fuchsia nodes.
Required Associated Types§
Required Methods§
Sourcefn attr_get(
&self,
query: NodeAttributesQuery,
) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>
fn attr_get( &self, query: NodeAttributesQuery, ) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>
Returns attributes in fuchsia.io’s FIDL representation.
Sourcefn query_filesystem(&self) -> Result<FilesystemInfo, Status>
fn query_filesystem(&self) -> Result<FilesystemInfo, Status>
Queries the filesystem info.
Sourcefn open<F: Factory<Self>>(
&self,
path: &str,
flags: Flags,
create_attributes: Option<MutableNodeAttributes>,
query: NodeAttributesQuery,
factory: F,
) -> Result<F::Result, Status>
fn open<F: Factory<Self>>( &self, path: &str, flags: Flags, create_attributes: Option<MutableNodeAttributes>, query: NodeAttributesQuery, factory: F, ) -> Result<F::Result, Status>
Opens a node relative to this directory.
Sourcefn open_pipelined<F: Factory<Self>>(
&self,
paths: &[&str],
flags: Flags,
query: NodeAttributesQuery,
factory_fn: impl FnMut() -> F,
) -> impl Iterator<Item = Result<F::Result, Status>>
fn open_pipelined<F: Factory<Self>>( &self, paths: &[&str], flags: Flags, query: NodeAttributesQuery, factory_fn: impl FnMut() -> F, ) -> impl Iterator<Item = Result<F::Result, Status>>
Opens all nodes iteratively along the relative sub-paths given in paths.
Each item in paths is opened from the node returned by opening the previous item in
paths.
Sourcefn link_into(&self, target_dir: &Self, name: &str) -> Result<(), Status>
fn link_into(&self, target_dir: &Self, name: &str) -> Result<(), Status>
Links this node into target_dir with name.
Sourcefn unlink(&self, name: &str, flags: UnlinkFlags) -> Result<(), Status>
fn unlink(&self, name: &str, flags: UnlinkFlags) -> Result<(), Status>
Unlinks name from this directory.
Sourcefn rename(
&self,
old_path: &str,
new_directory: &Self,
new_path: &str,
) -> Result<(), Status>
fn rename( &self, old_path: &str, new_directory: &Self, new_path: &str, ) -> Result<(), Status>
Renames old_path in this directory to new_path in new_directory.
Sourcefn create_symlink(&self, name: &str, target: &[u8]) -> Result<Self, Status>
fn create_symlink(&self, name: &str, target: &[u8]) -> Result<Self, Status>
Creates a symlink in this directory.
Sourcefn read_partial(
&self,
offset: u64,
max: usize,
) -> Result<(Vec<u8>, bool), Status>
fn read_partial( &self, offset: u64, max: usize, ) -> Result<(Vec<u8>, bool), Status>
Returns (data, eof), where eof is true if we encountered the end of the file. If eof
is false, then it is still possible that a subsequent read would read no more i.e. the end
of the file might have been reached. This might return fewer bytes than max.
Sourcefn supports_vectored(&self) -> bool
fn supports_vectored(&self) -> bool
Returns true if vectored operations are supported.
Sourceunsafe fn readv(
&self,
offset: u64,
iovecs: &mut [zx_iovec_t],
) -> Result<usize, Status>
unsafe fn readv( &self, offset: u64, iovecs: &mut [zx_iovec_t], ) -> Result<usize, Status>
Reads into iovecs using a vectored read. This is only supported with a valid stream. See
supports_vectored above.
§Safety
Same as zx::Stream::readv.
Sourcefn writev(&self, offset: u64, iovecs: &[zx_iovec_t]) -> Result<usize, Status>
fn writev(&self, offset: u64, iovecs: &[zx_iovec_t]) -> Result<usize, Status>
Writes from iovecs using vectored write. This is only supported with a valid stream. See
supports_vectored above.
Sourcefn enable_verity(
&self,
descriptor: &zxio_fsverity_descriptor_t,
) -> Result<(), Status>
fn enable_verity( &self, descriptor: &zxio_fsverity_descriptor_t, ) -> Result<(), Status>
Enables fsverity on this file.
Sourcefn allocate(
&self,
offset: u64,
len: u64,
mode: AllocateMode,
) -> Result<(), Status>
fn allocate( &self, offset: u64, len: u64, mode: AllocateMode, ) -> Result<(), Status>
Allocates space for this file.
Sourcefn xattr_set(
&self,
name: &[u8],
value: &[u8],
mode: XattrSetMode,
) -> Result<(), Status>
fn xattr_set( &self, name: &[u8], value: &[u8], mode: XattrSetMode, ) -> Result<(), Status>
Sets an extended attribute.
Sourcefn xattr_remove(&self, name: &[u8]) -> Result<(), Status>
fn xattr_remove(&self, name: &[u8]) -> Result<(), Status>
Removes an extended attribute.
Sourcefn open_directory(&self) -> Result<Self::Directory, Status>
fn open_directory(&self) -> Result<Self::Directory, Status>
Opens a directory iterator for this node.
Provided Methods§
Sourcefn read<E>(
&self,
offset: u64,
len: usize,
callback: impl FnMut(Vec<u8>) -> Result<usize, E>,
map_err: impl FnOnce(Status) -> E,
) -> Result<usize, E>
fn read<E>( &self, offset: u64, len: usize, callback: impl FnMut(Vec<u8>) -> Result<usize, E>, map_err: impl FnOnce(Status) -> E, ) -> Result<usize, E>
Attempts to read len bytes and will only return fewer if it encounters the end of the
file, or an error. callback will be called for each chunk. If any bytes are successfully
passed to callback, read will return the total number of bytes successfully written and
any error encountered will be discarded.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".