Crate intercom

Source
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§

alloc
attributes
error
interfaces
logging
prelude
raw
registry
runtime
type_system
typelib

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.
ComBoxData
Type factory for the concrete COM coclass types.
ComItf
An incoming COM interface pointer.
ComRc
Reference counted handle to the ComBox data.
FormatError
GUID
Binary GUID format as defined for the COM interfaces.
Static__intercom_vtable_for_ClassFactory
VariantError

Enums§

IntercomString
Variant

Constants§

CLSID_ClassFactory
ClassFactory class ID.
IID_IClassFactory
IClassFactory interface ID.
IID_IErrorInfo
IErrorInfo interface ID.

Traits§

IClassFactory

Functions§

__gather_module_types

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.
RawComResult
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§

ExternInput
Derives the implementation of the trait ExternInput for a type.
ExternOutput
Derives the implementation of the trait ExternOutput for a type.
ExternType
Derives the implementation of the trait ExternType for a type.
ForeignType
Derives the implementation of the trait ForeignType for a type.