fidl::encoding

Trait ResourceTypeMarker

Source
pub trait ResourceTypeMarker: TypeMarker {
    type Borrowed<'a>;

    // Required method
    fn take_or_borrow(value: &mut Self::Owned) -> Self::Borrowed<'_>;
}
Expand description

A FIDL resource type marker.

Resource types are allowed to contain handles. As a result, they must be encoded by mutable reference so that handles can be zeroed out.

Required Associated Types§

Source

type Borrowed<'a>

The Rust type to use for encoding. This is a particular Encode<Self> type cheaply obtainable from &mut Self::Owned. There are three cases:

  • Special cases such as &mut [T] for vectors.
  • When Owned: HandleBased, it is Owned.
  • Otherwise, it is &mut Owned.

Required Methods§

Source

fn take_or_borrow(value: &mut Self::Owned) -> Self::Borrowed<'_>

Cheaply converts from &mut Self::Owned to Self::Borrowed. For HandleBased types this is “take” (it returns an owned handle and replaces value with Handle::invalid), and for all other types it is “borrow” (just converts from one reference to another).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§