Struct TypedValue

Source
#[repr(C)]
pub struct TypedValue<T>(/* private fields */);
Expand description

A statically typed Value.

It dereferences to Value and can be used everywhere Value references are accepted.

See the module documentation for more details.

Implementations§

Source§

impl<'a, T: FromValueOptional<'a> + SetValue> TypedValue<T>

Source

pub fn get(&'a self) -> Option<T>

Returns the value.

Types that don’t support a None value always return Some. See get_some.

Source

pub fn get_some(&'a self) -> T
where T: FromValue<'a>,

Returns the value.

This method is only available for types that don’t support a None value.

Source

pub fn set<U: ?Sized + SetValueOptional>(&mut self, value: Option<&U>)
where T: Borrow<U>,

Sets the value.

This method is only available for types that support a None value.

Source

pub fn set_none(&mut self)

Sets the value to None.

This method is only available for types that support a None value.

Source

pub fn set_some<U: ?Sized + SetValue>(&mut self, value: &U)
where T: Borrow<U>,

Sets the value.

Source§

impl<'a, T: FromValueOptional<'a> + SetValue + Send> TypedValue<T>

Methods from Deref<Target = Value>§

Source

pub fn downcast_ref<'a, T: FromValueOptional<'a> + SetValue>( &self, ) -> Option<&TypedValue<T>>

Tries to downcast to a &TypedValue.

Returns Some(&TypedValue<T>) if the value carries a type corresponding to T and None otherwise.

Source

pub fn get<'a, T: FromValueOptional<'a>>(&'a self) -> Option<T>

Tries to get a value of type T.

Returns Some if the type is correct and the value is not None.

This function doesn’t distinguish between type mismatches and correctly typed None values. Use downcast or is for that.

Source

pub fn is<'a, T: FromValueOptional<'a> + SetValue>(&self) -> bool

Returns true if the type of the value corresponds to T or is a sub-type of T.

Source

pub fn type_(&self) -> Type

Returns the type of the value.

Trait Implementations§

Source§

impl<T: Clone> Clone for TypedValue<T>

Source§

fn clone(&self) -> TypedValue<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for TypedValue<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, T: FromValueOptional<'a> + SetValue> From<&'a T> for TypedValue<T>

Source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for TypedValue<String>

Source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: FromValueOptional<'a> + SetValueOptional> From<Option<&'a T>> for TypedValue<T>

Source§

fn from(value: Option<&'a T>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Option<&'a str>> for TypedValue<String>

Source§

fn from(value: Option<&'a str>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<TypedValue<&'a str>> for TypedValue<String>

Source§

fn from(value: TypedValue<&str>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<TypedValue<String>> for TypedValue<&'a str>

Source§

fn from(value: TypedValue<String>) -> Self

Converts to this type from the input type.
Source§

impl<T: Send> From<TypedValue<T>> for SendValue

Source§

fn from(value: TypedValue<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<TypedValue<T>> for Value

Source§

fn from(value: TypedValue<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Deref for TypedValue<T>

Source§

type Target = Value

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Value

Dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for TypedValue<T>

§

impl<T> RefUnwindSafe for TypedValue<T>
where T: RefUnwindSafe,

§

impl<T> !Send for TypedValue<T>

§

impl<T> !Sync for TypedValue<T>

§

impl<T> Unpin for TypedValue<T>

§

impl<T> UnwindSafe for TypedValue<T>
where T: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.