Handle

Struct Handle 

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

A handle of unspecified type within a remote FDomain.

Implementations§

Source§

impl Handle

Source

pub fn id(&self) -> u32

Returns the ID of the Handle. This should be unique to the handle for its lifetime.

Source

pub fn has_client(&self) -> bool

Checks if there is an active client for this handle.

Only really useful if you are doing something when this function returning false, and you want to fail fast with a specific error.

Source

pub fn invalid() -> Self

Get an invalid handle.

Source

pub fn as_unowned<H: HandleBased>(&self) -> Unowned<H>

Convert this into an unowned handle (one that is borrowed and will not close when dropped).

An example:

let handle: &Handle = /* ... */;
let socket = handle.as_unowned::<fdomain_client::Socket>();
let mut buf: [u8; 4096] = [0; 4096];
socket.read(&mut buf[..]).await?;

This is only really useful for contexts in which the handles are going to be stored and retrieved from a data structure and potentially used as arbitrary handle-based data types.

Source§

impl Handle

Source

pub fn close(self) -> impl Future<Output = Result<(), Error>>

Close this handle. Surfaces errors that dropping the handle will not.

Source

pub fn replace( self, rights: Rights, ) -> impl Future<Output = Result<Handle, Error>>

Replace this handle with a new handle to the same object, with different rights.

Trait Implementations§

Source§

impl AsHandleRef for Handle

Source§

fn as_handle_ref(&self) -> HandleRef<'_>

Get a HandleRef referring to the handle contained in Self

Source§

fn object_type() -> ObjectType

Get the object type of this handle.

Source§

fn u32_id(&self) -> u32

Source§

fn signal_handle( &self, set: Signals, clear: Signals, ) -> impl Future<Output = Result<(), Error>>

Source§

fn domain(&self) -> Arc<Client>

Get the client supporting this handle. See fidl::Proxy::domain.
Source§

impl Debug for Handle

Source§

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

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

impl Drop for Handle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl EncodableAsHandle for Handle

Source§

type Dialect = FDomainResourceDialect

What resource dialect can encode this object as a handle.
Source§

impl<E: HandleEncoder + ?Sized> Encode<WireHandle, E> for Handle

Source§

fn encode( self, encoder: &mut E, out: &mut MaybeUninit<WireHandle>, _: (), ) -> Result<(), EncodeError>

Encodes this value into an encoder and output.
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self, W> = _

Whether the conversion from Self to W is equivalent to copying the raw bytes of Self. Read more
Source§

impl<E: HandleEncoder + ?Sized> EncodeOption<WireOptionalHandle, E> for Handle

Source§

fn encode_option( this: Option<Self>, encoder: &mut E, out: &mut MaybeUninit<WireOptionalHandle>, _: (), ) -> Result<(), EncodeError>

Encodes this optional value into an encoder and output.
Source§

impl From<AnyHandle> for Handle

Source§

fn from(item: AnyHandle) -> Handle

Converts to this type from the input type.
Source§

impl From<Channel> for Handle

Source§

fn from(other: Channel) -> Handle

Converts to this type from the input type.
Source§

impl<T: ProtocolMarker> From<ClientEnd<T>> for Handle

Source§

fn from(client: ClientEnd<T>) -> Handle

Converts to this type from the input type.
Source§

impl From<Event> for Handle

Source§

fn from(other: Event) -> Handle

Converts to this type from the input type.
Source§

impl From<Eventpair> for Handle

Source§

fn from(other: Eventpair) -> Handle

Converts to this type from the input type.
Source§

impl From<Handle> for Channel

Source§

fn from(other: Handle) -> Channel

Converts to this type from the input type.
Source§

impl<T: ProtocolMarker> From<Handle> for ClientEnd<T>

Source§

fn from(handle: Handle) -> Self

Converts to this type from the input type.
Source§

impl From<Handle> for Event

Source§

fn from(other: Handle) -> Event

Converts to this type from the input type.
Source§

impl From<Handle> for Eventpair

Source§

fn from(other: Handle) -> Eventpair

Converts to this type from the input type.
Source§

impl<T: ProtocolMarker> From<Handle> for ServerEnd<T>

Source§

fn from(handle: Handle) -> Self

Converts to this type from the input type.
Source§

impl From<Handle> for Socket

Source§

fn from(other: Handle) -> Socket

Converts to this type from the input type.
Source§

impl From<Handle> for WireHandle

Source§

fn from(handle: Handle) -> WireHandle

Converts to this type from the input type.
Source§

impl<T: ProtocolMarker> From<ServerEnd<T>> for Handle

Source§

fn from(server: ServerEnd<T>) -> Handle

Converts to this type from the input type.
Source§

impl From<Socket> for Handle

Source§

fn from(other: Socket) -> Handle

Converts to this type from the input type.
Source§

impl FromWire<WireHandle> for Handle

Source§

fn from_wire(wire: WireHandle) -> Self

Converts the given wire to this type.
Source§

const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _

Whether the conversion from W to Self is equivalent to copying the raw bytes of W. Read more
Source§

impl FromWireOption<WireOptionalHandle> for Handle

Source§

fn from_wire_option(wire: WireOptionalHandle) -> Option<Self>

Converts the given wire to an option of this type.
Source§

impl HandleBased for Handle

Source§

fn invalidate(&mut self)

Drop ownership of this handle and make it invalid, without closing the handle.
Source§

fn close(self) -> impl Future<Output = Result<(), Error>>

Closes this handle. Surfaces errors that dropping the handle will not.
Source§

fn duplicate_handle( &self, rights: Rights, ) -> impl Future<Output = Result<Self, Error>>

Duplicate this handle.
Source§

fn replace_handle( self, rights: Rights, ) -> impl Future<Output = Result<Self, Error>>

Replace this handle with an equivalent one with different rights.
Source§

fn into_handle(self) -> Handle

Convert this handle-based value into a pure Handle.
Source§

fn from_handle(handle: Handle) -> Self

Construct a new handle-based value from a Handle.
Source§

fn into_handle_based<H: HandleBased>(self) -> H

Turn this handle-based value into one of a different type.
Source§

fn from_handle_based<H: HandleBased>(h: H) -> Self

Turn another handle-based type into this one.
Source§

impl HandleFor<FDomainResourceDialect> for Handle

Source§

type HandleInfo = HandleInfo

Handle info used in this dialect. Read more
Source§

fn invalid() -> Self

Produce an invalid version of Handle used as a place filler when we remove handles from an array.
Source§

fn is_invalid(&self) -> bool

Check whether a handle is invalid.
Source§

impl Hash for Handle

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Handle

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Handle

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Handle

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Handle

Auto Trait Implementations§

§

impl Freeze for Handle

§

impl !RefUnwindSafe for Handle

§

impl Send for Handle

§

impl Sync for Handle

§

impl Unpin for Handle

§

impl !UnwindSafe for Handle

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, 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, W> FromWireOption<WireBox<'_, W>> for T
where T: FromWire<W>,

Source§

fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>

Converts the given wire to an option of this type.
§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,