Skip to main content

RemoteIo

Struct RemoteIo 

Source
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

Source

pub fn new(proxy: NodeSynchronousProxy) -> Self

Source

pub fn with_stream(proxy: NodeSynchronousProxy, stream: Stream) -> Self

Source

pub fn into_proxy(self) -> NodeSynchronousProxy

Source

pub fn clone_proxy(&self) -> Result<NodeSynchronousProxy, Status>

Clones (in the fuchsia.unknown.Clonable sense) the underlying proxy.

Source

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.

Trait Implementations§

Source§

impl SyncIo for RemoteIo

Source§

fn attr_get( &self, query: NodeAttributesQuery, ) -> Result<(MutableNodeAttributes, ImmutableNodeAttributes), Status>

Returns attributes in fuchsia.io’s FIDL representation.

Source§

fn attr_set(&self, attributes: MutableNodeAttributes) -> Result<(), Status>

Sets attributes.

Source§

fn open<F: Factory<Self>>( &self, path: &str, flags: Flags, create_attributes: Option<MutableNodeAttributes>, query: NodeAttributesQuery, factory: F, ) -> Result<F::Result, Status>

Wraps fuchsia.io/Directory’s Open.

Source§

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.

factory_fn is used to create the factory argument to create_with_on_representation.

The return vector can be smaller than the initial paths vector, and execution will always stop with the first error appending an Err(status) into the results.

NOTE: To prevent opening and writing through non-directory nodes, this function adds fio::Flags::PROTOCOL_DIRECTORY | fio::Flags::PROTOCOL_SYMLINK to intermediate components.

Source§

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.

Source§

fn write(&self, offset: u64, data: &[u8]) -> Result<usize, Status>

Writes data at offset.

Source§

fn supports_vectored(&self) -> bool

Returns true if vectored operations are supported.

Source§

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.

Source§

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.

Source§

fn truncate(&self, length: u64) -> Result<(), Status>

Wraps fuchsia.io/File’s Truncate.

Source§

fn vmo_get(&self, flags: VmarFlags) -> Result<Vmo, Status>

Returns a VMO backing the file.

Source§

fn sync(&self) -> Result<(), Status>

Wraps fuchsia.io/Node’s Sync.

Wraps fuchsia.io/Node’s LinkInto.

Wraps fuchsia.io/Directory’s Unlink.

Source§

fn rename( &self, old_path: &str, new_directory: &Self, new_path: &str, ) -> Result<(), Status>

Wraps fuchsia.io/Directory’s Rename.

Wraps fuchsia.io/Directory’s CreateSymlink.

Source§

fn enable_verity( &self, descriptor: &zxio_fsverity_descriptor_t, ) -> Result<(), Status>

Wraps fuchsia.io/File’s EnableVerity.

Source§

fn allocate( &self, offset: u64, len: u64, mode: AllocateMode, ) -> Result<(), Status>

Wraps fuchsia.io/File’s Allocate.

Source§

fn xattr_get(&self, name: &[u8]) -> Result<Vec<u8>, Status>

Wraps fuchsia.io/Node’s GetExtendedAttribute.

Source§

fn xattr_set( &self, name: &[u8], value: &[u8], mode: XattrSetMode, ) -> Result<(), Status>

Wraps fuchsia.io/Node’s SetExtendedAttribute.

Source§

fn xattr_remove(&self, name: &[u8]) -> Result<(), Status>

Wraps fuchsia.io/Node’s RenoveExtendedAttribute.

Source§

fn xattr_list(&self) -> Result<Vec<Vec<u8>>, Status>

Wraps fuchsia.io/Node’s ListExtendedAttributes.

Source§

type Directory = RemoteDirectory

Source§

fn query_filesystem(&self) -> Result<FilesystemInfo, Status>

Queries the filesystem info.
Source§

fn open_directory(&self) -> Result<Self::Directory, Status>

Opens a directory iterator for this node.
Source§

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.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.