pub struct RemoteIo { /* private fields */ }Expand description
Wraps a proxy and optional stream and provides wrappers around most fuchsia.io methods.
NOTE: The caller must take care to call appropriate methods for the underlying type. Calling the wrong methods (e.g. calling file methods on a directory) will result in the connection being closed.
Implementations§
Source§impl RemoteIo
impl RemoteIo
pub fn new(proxy: NodeSynchronousProxy) -> Self
pub fn with_stream(proxy: NodeSynchronousProxy, stream: Stream) -> Self
pub fn into_proxy(self) -> NodeSynchronousProxy
Sourcepub fn attr_get(
&self,
query: NodeAttributesQuery,
) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>
pub fn attr_get( &self, query: NodeAttributesQuery, ) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>
Returns attributes in fuchsia.io’s FIDL representation.
Sourcepub fn attr_get_zxio(
&self,
query: NodeAttributesQuery,
) -> Result<zxio_node_attributes_t, Status>
pub fn attr_get_zxio( &self, query: NodeAttributesQuery, ) -> Result<zxio_node_attributes_t, Status>
Returns attributes mapped to zxio_node_attributes_t
NOTE: Not all attributes are supported. See zxio_attr_from_fidl above for supported
attributes.
Sourcepub fn attr_set(&self, attributes: MutableNodeAttributes) -> Result<(), Status>
pub fn attr_set(&self, attributes: MutableNodeAttributes) -> Result<(), Status>
Sets attributes.
Sourcepub fn open<F: Factory>(
&self,
path: &str,
flags: Flags,
create_attributes: Option<MutableNodeAttributes>,
query: NodeAttributesQuery,
factory: F,
) -> Result<(F::Result, zxio_node_attributes_t, Option<SelinuxContext>), Status>
pub fn open<F: Factory>( &self, path: &str, flags: Flags, create_attributes: Option<MutableNodeAttributes>, query: NodeAttributesQuery, factory: F, ) -> Result<(F::Result, zxio_node_attributes_t, Option<SelinuxContext>), Status>
Wraps fuchsia.io/Directory’s Open.
Sourcepub fn read_partial(
&self,
offset: u64,
max: usize,
) -> Result<(Vec<u8>, bool), Status>
pub 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.
Sourcepub 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>
pub 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.
Sourcepub fn supports_vectored(&self) -> bool
pub fn supports_vectored(&self) -> bool
Returns true if vectored operations are supported.
Sourcepub unsafe fn readv(
&self,
offset: u64,
iovecs: &mut [zx_iovec_t],
) -> Result<usize, Status>
pub 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.
Sourcepub fn writev(
&self,
offset: u64,
iovecs: &[zx_iovec_t],
) -> Result<usize, Status>
pub 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.
Sourcepub fn close_and_update_access_time(self)
pub fn close_and_update_access_time(self)
Closes and updates access time asynchronously.
Sourcepub fn clone_proxy(&self) -> Result<NodeSynchronousProxy, Status>
pub fn clone_proxy(&self) -> Result<NodeSynchronousProxy, Status>
Clones (in the fuchsia.unknown.Clonable sense) the underlying proxy.
Sourcepub fn link_into(&self, target_dir: &Self, name: &str) -> Result<(), Status>
pub fn link_into(&self, target_dir: &Self, name: &str) -> Result<(), Status>
Wraps fuchsia.io/Node’s LinkInto.
Sourcepub fn unlink(&self, name: &str, flags: UnlinkFlags) -> Result<(), Status>
pub fn unlink(&self, name: &str, flags: UnlinkFlags) -> Result<(), Status>
Wraps fuchsia.io/Directory’s Unlink.
Sourcepub fn rename(
&self,
old_path: &str,
new_directory: &Self,
new_path: &str,
) -> Result<(), Status>
pub fn rename( &self, old_path: &str, new_directory: &Self, new_path: &str, ) -> Result<(), Status>
Wraps fuchsia.io/Directory’s Rename.
Sourcepub fn create_symlink(
&self,
name: &str,
target: &[u8],
) -> Result<RemoteIo, Status>
pub fn create_symlink( &self, name: &str, target: &[u8], ) -> Result<RemoteIo, Status>
Wraps fuchsia.io/Directory’s CreateSymlink.
Sourcepub fn enable_verity(
&self,
descriptor: &zxio_fsverity_descriptor_t,
) -> Result<(), Status>
pub fn enable_verity( &self, descriptor: &zxio_fsverity_descriptor_t, ) -> Result<(), Status>
Wraps fuchsia.io/File’s EnableVerity.
Sourcepub fn allocate(
&self,
offset: u64,
len: u64,
mode: AllocateMode,
) -> Result<(), Status>
pub fn allocate( &self, offset: u64, len: u64, mode: AllocateMode, ) -> Result<(), Status>
Wraps fuchsia.io/File’s Allocate.
Sourcepub fn xattr_get(&self, name: &[u8]) -> Result<Vec<u8>, Status>
pub fn xattr_get(&self, name: &[u8]) -> Result<Vec<u8>, Status>
Wraps fuchsia.io/Node’s GetExtendedAttribute.
Sourcepub fn xattr_set(
&self,
name: &[u8],
value: &[u8],
mode: XattrSetMode,
) -> Result<(), Status>
pub fn xattr_set( &self, name: &[u8], value: &[u8], mode: XattrSetMode, ) -> Result<(), Status>
Wraps fuchsia.io/Node’s SetExtendedAttribute.
Sourcepub fn xattr_remove(&self, name: &[u8]) -> Result<(), Status>
pub fn xattr_remove(&self, name: &[u8]) -> Result<(), Status>
Wraps fuchsia.io/Node’s RenoveExtendedAttribute.