Skip to main content

OpaqueContextPtr

Struct OpaqueContextPtr 

Source
pub struct OpaqueContextPtr<T>(/* private fields */);
Expand description

Wraps a context pointer such that it can be passed to the Afia host, but it cannot be accessed by the site component.

This is useful when the component is already holding an &mut T reference and wishes to avoid unintentionally creating two mutable references.

TODO: Not sure whether the afia-component will eventually abstract this away such that the user does not need to use it… so… not including an example for now.

Implementations§

Source§

impl<T> OpaqueContextPtr<T>

Source

pub fn to_i32(&self) -> i32

Get an i32 that can get sent from the component to the Afia host.

TODO: Make the afia-component methods that call the Afia host take this [OpaqueContextPointer] as an argument and then we can use Context::to_isize to convert it to isize from within afia-component. Then we can delete this to_i32 method. This way the site component can’t get access to the underlying value, making this a truly opaque wrapper.

Trait Implementations§

Source§

impl<T> Context for OpaqueContextPtr<T>

Source§

fn to_isize(&self, _: CratePrivate) -> isize

Get an isize representation of the Context .

Auto Trait Implementations§

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> 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.

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.