Skip to main content

OptionView

Struct OptionView 

Source
pub struct OptionView<'a> { /* private fields */ }
Expand description

Read-only view over an OptionMap borrowed across the FFI.

The plugin contract hands the loader-owned &OptionMap to the plugin for the duration of create; this wrapper gives plugin authors a typed accessor surface without forcing them to construct a HashMap<String, String> themselves.

Implementations§

Source§

impl<'a> OptionView<'a>

Source

pub fn new(inner: &'a OptionMap) -> Self

Wrap a borrow over an option map. The macro-generated entry point typically reinterprets the incoming *const Options as &OptionMap and hands it here.

Source

pub unsafe fn from_raw_ptr(ptr: *const c_void) -> Option<Self>

Wrap a raw pointer that the loader produced. The pointer must point at a value layout-compatible with OptionMap and remain valid for the borrow. A NULL pointer yields None.

§Safety

ptr must either be NULL or point at a value that is layout-compatible with OptionMap and valid for 'a.

Source

pub fn get_str(&self, key: &str) -> Option<&str>

Read a string option. Returns None if the key is absent or the value isn’t a OptionValue::String.

Source

pub fn get_u32(&self, key: &str) -> Option<u32>

Read a u32 option. Returns None if the key is absent or the value isn’t a OptionValue::U32.

Source

pub fn get_map(&self, key: &str) -> Option<OptionView<'_>>

Read a nested map option. Returns None if the key is absent or the value isn’t a OptionValue::Map.

Source

pub fn is_empty(&self) -> bool

True if the map contains no entries.

Auto Trait Implementations§

§

impl<'a> Freeze for OptionView<'a>

§

impl<'a> RefUnwindSafe for OptionView<'a>

§

impl<'a> Send for OptionView<'a>

§

impl<'a> Sync for OptionView<'a>

§

impl<'a> Unpin for OptionView<'a>

§

impl<'a> UnsafeUnpin for OptionView<'a>

§

impl<'a> UnwindSafe for OptionView<'a>

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.