Trait fidl::encoding::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).

Object Safety§

This trait is not object safe.

Implementors§