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

Defines the COM library.

Defines a COM library sub-module.

Structs

Represents a borrowed BSTR string.

An owned BSTR string Rust type.

Pointer to a COM-enabled Rust struct.

Type factory for the concrete COM coclass types.

An incoming COM interface pointer.

Reference counted handle to the ComBox data.

Binary GUID format as defined for the COM interfaces.

Enums

Constants

ClassFactory class ID.

IClassFactory interface ID.

IErrorInfo interface ID.

Traits

Functions

Type Definitions

Class ID GUID.

Basic COM result type.

Raw COM pointer type. Interface ID GUID.

A reference to a class ID.

A reference to an interface ID.

Basic COM result type.

Attribute Macros

Defines a COM class that implements one or more COM interfaces.

Defines an intercom interface.

Derive Macros

Derives the implementation of the trait ExternInput for a type.

Derives the implementation of the trait ExternOutput for a type.

Derives the implementation of the trait ExternType for a type.

Derives the implementation of the trait ForeignType for a type.