Crate intercom [] [src]

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.

#![feature(proc_macro)]

use intercom::{com_library, com_class, com_interface, com_impl, ComResult};

// Define COM classes to expose from this library.
#[com_library(AUTO_GUID, Calculator)]

// Define the COM class and the interfaces it implements.
#[com_class(AUTO_GUID, Calculator)]
struct Calculator;

// Define the implementation for the class. The COM interface is defined
// implicitly by the `impl`.
#[com_interface(AUTO_GUID)]
#[com_impl]
impl Calculator {

    // Intercom requires a `new` method with no parameters for all classes.
    fn new() -> Calculator { 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 intercom_attributes::*;

Structs

BStr

A Rust wrapper for the BSTR string type.

ComBox

Type factory for the concrete COM coclass types.

ComError

Error structure containing the available information on a COM error.

ComItf

An incoming COM interface pointer.

ComRc

Reference counted handle to the ComBox data.

ErrorInfo

Error info COM object data.

GUID

Binary GUID format as defined for the COM interfaces.

HRESULT

COM method status code.

Constants

E_ABORT
E_ACCESSDENIED
E_FAIL
E_INVALIDARG
E_NOINTERFACE
E_NOTIMPL
E_POINTER
IID_IClassFactory

IClassFactory interface ID.

IID_IErrorInfo

IErrorInfo interface ID.

IID_ISupportErrorInfo

ISupportErrorInfo interface ID.

IID_IUnknown

IUnknown interface ID.

RPC_E_CALL_CANCELED
RPC_E_CALL_REJECTED
RPC_E_DISCONNECTED
RPC_E_TIMEOUT
STG_E_FILENOTFOUND
S_FALSE
S_OK

Traits

CoClass

Trait required by any COM coclass type.

ISupportErrorInfo

The ISupportErrorInfo COM interface.

IUnknown

The IUnknown COM interface.

Functions

get_last_error

Gets the last COM error that occurred on the current thread.

return_hresult

Extracts the HRESULT from the error result and stores the extended error information in thread memory so it can be fetched by the COM client.

Type Definitions

CLSID

Class ID GUID.

ComResult

Basic COM result type.

IID

Interface ID GUID.

REFCLSID

A reference to a class ID.

REFIID

A reference to an interface ID.

RawComPtr

Raw COM pointer type.