Crate oaidl[−][src]
Introduction
A module to handle conversion to and from common OLE/COM types - VARIANT, SAFEARRAY, and BSTR.
This module provides some convenience types as well as traits and trait implementations for
built in rust types - u8
, i8
, u1
, i16
, u32
, i32
, u64
, f32
, f64
, String
, bool
to and from VARIANT
structures.
In addition, Vec<T>
can be converted into a SAFEARRAY
where T: i8
, u8
, u16
, i16
, u32
, i32
, String
, f32
, f64
, bool
.
In addition, IUnknown
, IDispatch
pointers can be marshalled back and forth across boundaries.
There are some convenience types provided for further types that VARIANT/SAFEARRAY support:
SCode
, Int
, UInt
, Currency
, Date
, DecWrapper
, VtEmpty
, VtNull
The relevant traits to use are: BStringExt
, SafeArrayElement
, SafeArrayExt
, and VariantExt
Examples
An example of how to use the module:
extern crate oaidl; extern crate winapi; use winapi::um::oaidl::VARIANT; use oaidl::{VariantExt}; //simulate an FFI function unsafe fn c_masq(s: *mut VARIANT, p: *mut VARIANT) { println!("vt of s: {}", (*s).n1.n2_mut().vt); println!("vt of p: {}", (*p).n1.n2_mut().vt); //free the memory allocated for these VARIANTS let s = *s; let p = *p; } fn main() { let mut u = 1337u32; let mut sr = String::from("Turing completeness."); let p = match u.into_variant() { Ok(pvar) => pvar, Err(ex) => panic!(ex), }; let s = match sr.into_variant() { Ok(pvar) => pvar, Err(ex) => panic!(ex) }; unsafe {c_masq(s.as_ptr(), p.as_ptr())}; }
Structs
Currency |
Helper type for the OLE/COM+ type CY |
Date |
Helper type for the OLE/COM+ type DATE |
DecWrapper |
Helper type for the OLE/COM+ type DECIMAL |
DroppableBString |
Struct that holds pointer to Sys* allocated memory. It will automatically free the memory via the Sys* functions unless it has been consumed. |
Int |
Helper type for the OLE/COM+ type INT |
Ptr |
Convenience type for holding value of |
SCode |
Helper type for the OLE/COM+ type SCODE |
UInt |
Helper type for the OLE/COM+ type UINT |
Variant |
Helper struct to wrap a VARIANT compatible type into a VT_VARIANT marked VARIANT |
VariantBool |
Helper type for the OLE/COM+ type VARIANT_BOOL |
VtEmpty |
Helper type for VT_EMPTY variants |
VtNull |
Helper type for VT_NULL variants |
Enums
BStringError |
Ways BString can fail. Currently just one way. |
ElementError |
Supererror type SafeArray element conversion errors |
FromSafeArrElemError |
Errors for converting from C/C++ data structure to Rust types |
FromSafeArrayError |
Represents the different ways converting from |
FromVariantError |
Encapsulates the ways converting from a |
IntoSafeArrElemError |
Errors for converting into C/C++ data structures from Rust types |
IntoSafeArrayError |
Represents the different ways converting into |
IntoVariantError |
Encapsulates errors that can occur during conversion into VARIANT |
SafeArrayError |
Supererror for SafeArray errors |
Traits
BStringExt |
This trait is implemented on String to enable the convenient and safe conversion of
It utilizes the Sys* functions to manage the allocated memory.
Generally you will want to use |
SafeArrayElement |
Helper trait implemented for types that can be converted into a safe array.
Generally, don't implement this yourself without care.
Implemented for types:
* i8, u8, i16, u16, i32, u32
* bool, f32, f64
* String, Variant |
SafeArrayExt |
Workhorse trait and main interface for converting to/from SAFEARRAY
Default impl is on |
VariantExt |
Trait implemented to convert the type into a VARIANT Do not implement this yourself without care. |