Trait ResourceTypeMarker

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§

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§

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§

§

impl ResourceTypeMarker for Ambiguous1

§

impl ResourceTypeMarker for Ambiguous2

§

impl<T> ResourceTypeMarker for Boxed<T>

§

impl<T> ResourceTypeMarker for Optional<T>

§

impl<T> ResourceTypeMarker for OptionalUnion<T>

§

impl<T, const N: usize> ResourceTypeMarker for Array<T, N>

§

type Borrowed<'a> = &'a mut [<T as TypeMarker>::Owned; N]

§

impl<T, const N: usize> ResourceTypeMarker for Vector<T, N>

§

type Borrowed<'a> = &'a mut [<T as TypeMarker>::Owned]

§

impl<T, const OBJECT_TYPE: u32, const RIGHTS: u32> ResourceTypeMarker for HandleType<T, OBJECT_TYPE, RIGHTS>
where T: 'static + EncodableAsHandle,

§

type Borrowed<'a> = T