Zxio

Struct Zxio 

Source
pub struct Zxio { /* private fields */ }
Expand description

A handle to a zxio object.

Note: the underlying storage backing the object is pinned on the heap because it can contain self referential data.

Implementations§

Source§

impl Zxio

Source

pub fn new_socket<S: ServiceConnector>( domain: c_int, socket_type: c_int, protocol: c_int, _: ZxioSocketCreationOptions<'_>, ) -> Result<Result<Self, ZxioErrorCode>, Status>

Source

pub fn create(handle: NullableHandle) -> Result<Zxio, Status>

Source

pub fn release(self) -> Result<NullableHandle, Status>

Source

pub fn with_token_resolver(self, resolver: Arc<dyn ZxioTokenResolver>) -> Self

Updates self with a new token resolver. Can be called only when there are no weak references to self.

Source

pub fn open( &self, path: &str, flags: Flags, options: ZxioOpenOptions<'_, '_>, ) -> Result<Self, Status>

Source

pub fn create_with_on_representation( handle: NullableHandle, attributes: Option<&mut zxio_node_attributes_t>, ) -> Result<Zxio, Status>

Source

pub fn open_node( &self, path: &str, flags: Flags, attributes: Option<&mut zxio_node_attributes_t>, ) -> Result<Self, Status>

Opens a limited node connection (similar to O_PATH).

Source

pub fn read(&self, data: &mut [u8]) -> Result<usize, Status>

Source

pub unsafe fn readv(&self, data: &[zx_iovec]) -> Result<usize, Status>

Performs a vectorized read, returning the number of bytes read to data.

§Safety

The caller must check the returned Result to make sure the buffers provided are valid. The caller must provide pointers that are compatible with the backing implementation of zxio.

This call allows writing to arbitrary memory locations. It is up to the caller to make sure that calling this method does not result in undefined behaviour.

Source

pub fn deep_clone(&self) -> Result<Zxio, Status>

Source

pub fn clone_handle(&self) -> Result<NullableHandle, Status>

Source

pub fn downgrade(&self) -> ZxioWeak

Source

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

Source

pub unsafe fn readv_at( &self, offset: u64, data: &[zx_iovec], ) -> Result<usize, Status>

Performs a vectorized read at an offset, returning the number of bytes read to data.

§Safety

The caller must check the returned Result to make sure the buffers provided are valid. The caller must provide pointers that are compatible with the backing implementation of zxio.

This call allows writing to arbitrary memory locations. It is up to the caller to make sure that calling this method does not result in undefined behaviour.

Source

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

Source

pub unsafe fn writev(&self, data: &[zx_iovec]) -> Result<usize, Status>

Performs a vectorized write, returning the number of bytes written from data.

§Safety

The caller must check the returned Result to make sure the buffers provided are valid. The caller must provide pointers that are compatible with the backing implementation of zxio.

This call allows reading from arbitrary memory locations. It is up to the caller to make sure that calling this method does not result in undefined behaviour.

Source

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

Source

pub unsafe fn writev_at( &self, offset: u64, data: &[zx_iovec], ) -> Result<usize, Status>

Performs a vectorized write at an offset, returning the number of bytes written from data.

§Safety

The caller must check the returned Result to make sure the buffers provided are valid. The caller must provide pointers that are compatible with the backing implementation of zxio.

This call allows reading from arbitrary memory locations. It is up to the caller to make sure that calling this method does not result in undefined behaviour.

Source

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

Source

pub fn seek( &self, seek_origin: SeekOrigin, offset: i64, ) -> Result<usize, Status>

Source

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

Source

pub fn attr_get( &self, query: zxio_node_attr_has_t, ) -> Result<zxio_node_attributes_t, Status>

Source

pub fn close_and_update_access_time(self) -> Result<(), Status>

Source

pub fn attr_get_with_root_hash( &self, query: zxio_node_attr_has_t, fsverity_root_hash: &mut [u8; 64], ) -> Result<zxio_node_attributes_t, Status>

Assumes that the caller has set query.fsverity_root_hash to true.

Source

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

Source

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

Source

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

Source

pub fn wait_begin( &self, zxio_signals: zxio_signals_t, ) -> (Unowned<'_, NullableHandle>, Signals)

Source

pub fn wait_end(&self, signals: Signals) -> zxio_signals_t

Source

pub fn create_dirent_iterator(&self) -> Result<DirentIterator<'_>, Status>

Source

pub fn connect(&self, addr: &[u8]) -> Result<Result<(), ZxioErrorCode>, Status>

Source

pub fn bind(&self, addr: &[u8]) -> Result<Result<(), ZxioErrorCode>, Status>

Source

pub fn listen(&self, backlog: i32) -> Result<Result<(), ZxioErrorCode>, Status>

Source

pub fn accept(&self) -> Result<Result<Zxio, ZxioErrorCode>, Status>

Source

pub fn getsockname(&self) -> Result<Result<Vec<u8>, ZxioErrorCode>, Status>

Source

pub fn getpeername(&self) -> Result<Result<Vec<u8>, ZxioErrorCode>, Status>

Source

pub fn getsockopt_slice( &self, level: u32, optname: u32, optval: &mut [u8], ) -> Result<Result<socklen_t, ZxioErrorCode>, Status>

Source

pub fn getsockopt( &self, level: u32, optname: u32, optlen: socklen_t, ) -> Result<Result<Vec<u8>, ZxioErrorCode>, Status>

Source

pub fn setsockopt( &self, level: i32, optname: i32, optval: &[u8], ) -> Result<Result<(), ZxioErrorCode>, Status>

Source

pub fn shutdown( &self, flags: ZxioShutdownFlags, ) -> Result<Result<(), ZxioErrorCode>, Status>

Source

pub fn sendmsg( &self, addr: &mut [u8], buffer: &mut [iovec], cmsg: &[ControlMessage], flags: u32, ) -> Result<Result<usize, ZxioErrorCode>, Status>

Source

pub fn recvmsg( &self, buffer: &mut [iovec], flags: u32, ) -> Result<Result<RecvMessageInfo, ZxioErrorCode>, Status>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for Zxio

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Zxio

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Zxio

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Zxio

§

impl !RefUnwindSafe for Zxio

§

impl Send for Zxio

§

impl Sync for Zxio

§

impl Unpin for Zxio

§

impl !UnwindSafe for Zxio

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.