Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Empty,
    Null,
    Bool(bool),
    I32(i32),
    I64(i64),
    NullObject,
    U64(u64),
    F64(f64),
    Str(String),
    Object(Box<dyn Dispatch>),
}
Expand description

An owned value crossing the COM boundary, mapped from a VARIANT.

Variants§

§

Empty

VT_EMPTY, an uninitialized VARIANT.

§

Null

VT_NULL, SQL-style null.

§

Bool(bool)

VT_BOOL.

§

I32(i32)

VT_I4, a 32-bit signed integer.

§

I64(i64)

VT_I8, a 64-bit signed integer (handles, large counts).

§

NullObject

A null object reference (VT_DISPATCH holding no pointer).

Distinct from Self::Null, which is VT_NULL. A member that takes an object and documents “pass a null reference” wants this: VT_NULL is a different type and is refused with DISP_E_TYPEMISMATCH.

§

U64(u64)

An unsigned 64-bit integer (VT_UI8).

Distinct from Self::I64 because the engine matches numeric representation strictly: a property stored as unsigned rejects a signed variant rather than coercing it.

§

F64(f64)

VT_R8, a 64-bit float.

§

Str(String)

VT_BSTR, an owned UTF-8 copy of the BSTR.

§

Object(Box<dyn Dispatch>)

VT_DISPATCH, a nested COM object, ready to wrap.

Implementations§

Source§

impl Value

Source

pub const fn kind(&self) -> &'static str

The variant name, used in type-mismatch diagnostics.

Source

pub const fn as_i32(&self) -> Result<i32, ComError>

Reads the value as an i32 (VT_I4).

§Errors

ComError::UnexpectedType if the value is not an Value::I32.

Source

pub const fn as_i64(&self) -> Result<i64, ComError>

Reads the value as an i64 (VT_I8).

§Errors

ComError::UnexpectedType if the value is not an Value::I64.

Source

pub const fn as_f64(&self) -> Result<f64, ComError>

Reads the value as a f64 (VT_R8).

§Errors

ComError::UnexpectedType if the value is not an Value::F64.

Source

pub const fn as_bool(&self) -> Result<bool, ComError>

Reads the value as a bool (VT_BOOL).

§Errors

ComError::UnexpectedType if the value is not a Value::Bool.

Source

pub fn into_string(self) -> Result<String, ComError>

Consumes the value as an owned String (VT_BSTR).

§Errors

ComError::UnexpectedType if the value is not a Value::Str.

Source

pub fn into_object(self) -> Result<Box<dyn Dispatch>, ComError>

Consumes the value as a nested COM object (VT_DISPATCH).

§Errors

ComError::UnexpectedType if the value is not a Value::Object.

Trait Implementations§

Source§

impl Debug for Value

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl !UnwindSafe for Value

§

impl Freeze for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

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.