Expand description
Tools to define Rust components compatible with the COM protocol.
Intercom provides attributes to automatically derive extern
compatible
functions for Rust methods. These functions are compatible with COM binary
interface standard, which allows them to be used from any language that
supports COM.
§Examples
A basic example of a calculator type exposed as a COM object.
use intercom::{com_library, com_class, com_interface, ComResult};
// Define COM classes to expose from this library.
com_library!(class Calculator);
// Define the COM class and the interfaces it implements.
#[com_class(Self)]
#[derive(Default)]
struct Calculator;
// Define the implementation for the class. The COM interface is defined
// implicitly by the `impl`.
#[com_interface]
impl Calculator {
fn add(&self, a: i32, b: i32) -> ComResult<i32> { Ok(a + b) }
fn sub(&self, a: i32, b: i32) -> ComResult<i32> { Ok(a - b) }
}
The above library can be used for example from C# in the following manner.
void Main()
{
var calculator = new CalculatorLib.Calculator();
Console.WriteLine( calculator.Add( 1, 2 ) );
}
Re-exports§
pub use crate::error::load_error;
pub use crate::error::store_error;
pub use crate::error::ComError;
pub use crate::error::ErrorValue;
pub use type_system::ForeignType;
pub use crate::interfaces::IUnknown;
pub use crate::interfaces::ISupportErrorInfo;
Modules§
Macros§
- com_
library - Defines the COM library.
- com_
module - Defines a COM library sub-module.
Structs§
- BStr
- Represents a borrowed BSTR string.
- BString
- An owned BSTR string Rust type.
- ComBox
- Pointer to a COM-enabled Rust struct.
- ComBox
Data - Type factory for the concrete COM coclass types.
- ComItf
- An incoming COM interface pointer.
- ComRc
- Reference counted handle to the
ComBox
data. - Format
Error - GUID
- Binary GUID format as defined for the COM interfaces.
- Static__
intercom_ vtable_ for_ Class Factory - Variant
Error
Enums§
Constants§
- CLSID_
Class Factory ClassFactory
class ID.- IID_
IClass Factory IClassFactory
interface ID.- IID_
IError Info IErrorInfo
interface ID.
Traits§
Functions§
Type Aliases§
- CLSID
- Class ID GUID.
- CStr
- CString
- ComResult
- Basic COM result type.
- IID
- Raw COM pointer type. Interface ID GUID.
- REFCLSID
- A reference to a class ID.
- REFIID
- A reference to an interface ID.
- RawCom
Result - Basic COM result type.
Attribute Macros§
- com_
class - Defines a COM class that implements one or more COM interfaces.
- com_
interface - Defines an intercom interface.
Derive Macros§
- Extern
Input - Derives the implementation of the trait ExternInput for a type.
- Extern
Output - Derives the implementation of the trait ExternOutput for a type.
- Extern
Type - Derives the implementation of the trait ExternType for a type.
- Foreign
Type - Derives the implementation of the trait ForeignType for a type.