Trait Interface

Source
pub unsafe trait Interface: Sized + Clone {
    const IID: GUID;

    // Provided methods
    fn as_raw(&self) -> *mut c_void { ... }
    fn into_raw(self) -> *mut c_void { ... }
    unsafe fn from_raw(raw: *mut c_void) -> Self { ... }
    unsafe fn from_raw_borrowed(raw: &*mut c_void) -> Option<&Self> { ... }
    fn cast<T>(&self) -> Result<T, Error>
       where T: Interface { ... }
    fn cast_to_any<T>(&self) -> Result<&(dyn Any + 'static), Error>
       where T: ComObjectInner,
             <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T> { ... }
    fn is_object<T>(&self) -> bool
       where T: ComObjectInner,
             <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T> { ... }
    fn cast_object_ref<T>(&self) -> Result<&<T as ComObjectInner>::Outer, Error>
       where T: ComObjectInner,
             <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T> { ... }
    fn cast_object<T>(&self) -> Result<ComObject<T>, Error>
       where T: ComObjectInner,
             <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T> { ... }
    fn downgrade(&self) -> Result<Weak<Self>, Error> { ... }
    unsafe fn query(
        &self,
        iid: *const GUID,
        interface: *mut *mut c_void,
    ) -> HRESULT { ... }
    fn to_ref(&self) -> InterfaceRef<'_, Self> { ... }
}
Expand description

Provides low-level access to an interface vtable.

This trait is automatically implemented by the generated bindings and should not be implemented manually.

§Safety

Required Associated Constants§

Source

const IID: GUID

The GUID associated with the interface.

Provided Methods§

Source

fn as_raw(&self) -> *mut c_void

Returns the raw COM interface pointer. The resulting pointer continues to be owned by the Interface implementation.

Source

fn into_raw(self) -> *mut c_void

Returns the raw COM interface pointer and releases ownership. It the caller’s responsibility to release the COM interface pointer.

Source

unsafe fn from_raw(raw: *mut c_void) -> Self

Creates an Interface by taking ownership of the raw COM interface pointer.

§Safety

The raw pointer must be owned by the caller and represent a valid COM interface pointer. In other words, it must point to a vtable beginning with the IUnknown function pointers and match the vtable of Interface.

Source

unsafe fn from_raw_borrowed(raw: &*mut c_void) -> Option<&Self>

Creates an Interface that is valid so long as the raw COM interface pointer is valid.

§Safety

The raw pointer must be a valid COM interface pointer. In other words, it must point to a vtable beginning with the IUnknown function pointers and match the vtable of Interface.

Source

fn cast<T>(&self) -> Result<T, Error>
where T: Interface,

Attempts to cast the current interface to another interface using QueryInterface.

The name cast is preferred to query because there is a WinRT method named query but not one named cast.

Source

fn cast_to_any<T>(&self) -> Result<&(dyn Any + 'static), Error>
where T: ComObjectInner, <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T>,

This casts the given COM interface to [&dyn Any].

Applications should generally not call this method directly. Instead, use the Interface::cast_object_ref or Interface::cast_object methods.

T must be a type that has been annotated with #[implement]; this is checked at compile-time by the generic constraints of this method. However, note that the returned &dyn Any refers to the outer implementation object that was generated by #[implement], i.e. the MyApp_Impl type, not the inner MyApp type.

If the given object is not a Rust object, or is a Rust object but not T, or is a Rust object that contains non-static lifetimes, then this function will return Err(E_NOINTERFACE).

§Safety

IMPORTANT!! This uses a non-standard protocol for QueryInterface! The DYNAMIC_CAST_IID IID identifies this protocol, but there is no IDynamicCast interface. Instead, objects that recognize DYNAMIC_CAST_IID simply store their &dyn Any directly at the interface pointer that was passed to QueryInterface. This means that the returned value has a size that is twice as large (size_of::<&dyn Any>() == 2 * size_of::<*const c_void>()`).

This means that callers that use this protocol cannot simply pass &mut ptr for an ordinary single-pointer-sized pointer. Only this method understands this protocol.

Another part of this protocol is that the implementation of QueryInterface does not AddRef the object. The caller must guarantee the liveness of the COM object. In Rust, this means tying the lifetime of the IUnknown* that we used for the QueryInterface call to the lifetime of the returned &dyn Any value.

This method preserves type safety and relies on these invariants:

  • All QueryInterface implementations that recognize DYNAMIC_CAST_IID are generated by the #[implement] macro and respect the rules described here.
Source

fn is_object<T>(&self) -> bool
where T: ComObjectInner, <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T>,

Returns true if the given COM interface refers to an implementation of T.

T must be a type that has been annotated with #[implement]; this is checked at compile-time by the generic constraints of this method.

If the given object is not a Rust object, or is a Rust object but not T, or is a Rust object that contains non-static lifetimes, then this function will return false.

Source

fn cast_object_ref<T>(&self) -> Result<&<T as ComObjectInner>::Outer, Error>
where T: ComObjectInner, <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T>,

This casts the given COM interface to [&dyn Any]. It returns a reference to the “outer” object, e.g. &MyApp_Impl, not the inner &MyApp object.

T must be a type that has been annotated with #[implement]; this is checked at compile-time by the generic constraints of this method. However, note that the returned &dyn Any refers to the outer implementation object that was generated by #[implement], i.e. the MyApp_Impl type, not the inner MyApp type.

If the given object is not a Rust object, or is a Rust object but not T, or is a Rust object that contains non-static lifetimes, then this function will return Err(E_NOINTERFACE).

The returned value is borrowed. If you need an owned (counted) reference, then use Interface::cast_object.

Source

fn cast_object<T>(&self) -> Result<ComObject<T>, Error>
where T: ComObjectInner, <T as ComObjectInner>::Outer: Any + 'static + IUnknownImpl<Impl = T>,

This casts the given COM interface to [&dyn Any]. It returns a reference to the “outer” object, e.g. MyApp_Impl, not the inner MyApp object.

T must be a type that has been annotated with #[implement]; this is checked at compile-time by the generic constraints of this method. However, note that the returned &dyn Any refers to the outer implementation object that was generated by #[implement], i.e. the MyApp_Impl type, not the inner MyApp type.

If the given object is not a Rust object, or is a Rust object but not T, or is a Rust object that contains non-static lifetimes, then this function will return Err(E_NOINTERFACE).

The returned value is an owned (counted) reference; this function calls AddRef on the underlying COM object. If you do not need an owned reference, then you can use the Interface::cast_object_ref method instead, and avoid the cost of AddRef / Release.

Source

fn downgrade(&self) -> Result<Weak<Self>, Error>

Attempts to create a Weak reference to this object.

Source

unsafe fn query(&self, iid: *const GUID, interface: *mut *mut c_void) -> HRESULT

Call QueryInterface on this interface

§Safety

interface must be a non-null, valid pointer for writing an interface pointer.

Source

fn to_ref(&self) -> InterfaceRef<'_, Self>

Creates an InterfaceRef for this reference. The InterfaceRef tracks lifetimes statically, and eliminates the need for dynamic reference count adjustments (AddRef/Release).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Interface for IFabricApplicationHealthResult

Source§

impl Interface for IFabricApplicationManagementClient2

Source§

impl Interface for IFabricApplicationManagementClient3

Source§

impl Interface for IFabricApplicationManagementClient4

Source§

impl Interface for IFabricApplicationManagementClient5

Source§

impl Interface for IFabricApplicationManagementClient6

Source§

impl Interface for IFabricApplicationManagementClient7

Source§

impl Interface for IFabricApplicationManagementClient8

Source§

impl Interface for IFabricApplicationManagementClient9

Source§

impl Interface for IFabricApplicationManagementClient10

Source§

impl Interface for IFabricApplicationManagementClient

Source§

impl Interface for IFabricApplicationUpgradeProgressResult2

Source§

impl Interface for IFabricApplicationUpgradeProgressResult3

Source§

impl Interface for IFabricApplicationUpgradeProgressResult

Source§

impl Interface for IFabricChaosDescriptionResult

Source§

impl Interface for IFabricChaosEventsSegmentResult

Source§

impl Interface for IFabricChaosReportResult

Source§

impl Interface for IFabricChaosScheduleDescriptionResult

Source§

impl Interface for IFabricClientConnectionEventHandler2

Source§

impl Interface for IFabricClientConnectionEventHandler

Source§

impl Interface for IFabricClientSettings2

Source§

impl Interface for IFabricClientSettings

Source§

impl Interface for IFabricClientSettingsResult

Source§

impl Interface for IFabricClusterHealthResult

Source§

impl Interface for IFabricClusterManagementClient2

Source§

impl Interface for IFabricClusterManagementClient3

Source§

impl Interface for IFabricClusterManagementClient4

Source§

impl Interface for IFabricClusterManagementClient5

Source§

impl Interface for IFabricClusterManagementClient6

Source§

impl Interface for IFabricClusterManagementClient7

Source§

impl Interface for IFabricClusterManagementClient8

Source§

impl Interface for IFabricClusterManagementClient9

Source§

impl Interface for IFabricClusterManagementClient10

Source§

impl Interface for IFabricClusterManagementClient

Source§

impl Interface for IFabricDeployedApplicationHealthResult

Source§

impl Interface for IFabricDeployedServicePackageHealthResult

Source§

impl Interface for IFabricFaultManagementClient

Source§

impl Interface for IFabricGatewayInformationResult

Source§

impl Interface for IFabricGetApplicationListResult2

Source§

impl Interface for IFabricGetApplicationListResult

Source§

impl Interface for IFabricGetApplicationLoadInformationResult

Source§

impl Interface for IFabricGetApplicationNameResult

Source§

impl Interface for IFabricGetApplicationNetworkListResult

Source§

impl Interface for IFabricGetApplicationTypeListResult

Source§

impl Interface for IFabricGetApplicationTypePagedListResult

Source§

impl Interface for IFabricGetClusterHealthChunkResult

Source§

impl Interface for IFabricGetClusterLoadInformationResult

Source§

impl Interface for IFabricGetDeployedApplicationListResult

Source§

impl Interface for IFabricGetDeployedApplicationPagedListResult

Source§

impl Interface for IFabricGetDeployedCodePackageListResult

Source§

impl Interface for IFabricGetDeployedNetworkCodePackageListResult

Source§

impl Interface for IFabricGetDeployedNetworkListResult

Source§

impl Interface for IFabricGetDeployedReplicaListResult

Source§

impl Interface for IFabricGetDeployedServicePackageListResult

Source§

impl Interface for IFabricGetDeployedServiceReplicaDetailResult

Source§

impl Interface for IFabricGetDeployedServiceTypeListResult

Source§

impl Interface for IFabricGetNetworkApplicationListResult

Source§

impl Interface for IFabricGetNetworkListResult

Source§

impl Interface for IFabricGetNetworkNodeListResult

Source§

impl Interface for IFabricGetNodeListResult2

Source§

impl Interface for IFabricGetNodeListResult

Source§

impl Interface for IFabricGetNodeLoadInformationResult

Source§

impl Interface for IFabricGetPartitionListResult2

Source§

impl Interface for IFabricGetPartitionListResult

Source§

impl Interface for IFabricGetPartitionLoadInformationResult

Source§

impl Interface for IFabricGetProvisionedCodeVersionListResult

Source§

impl Interface for IFabricGetProvisionedConfigVersionListResult

Source§

impl Interface for IFabricGetRepairTaskListResult

Source§

impl Interface for IFabricGetReplicaListResult2

Source§

impl Interface for IFabricGetReplicaListResult

Source§

impl Interface for IFabricGetReplicaLoadInformationResult

Source§

impl Interface for IFabricGetRollingUpgradeMonitoringPolicyResult

Source§

impl Interface for IFabricGetServiceGroupMemberListResult

Source§

impl Interface for IFabricGetServiceGroupMemberTypeListResult

Source§

impl Interface for IFabricGetServiceListResult2

Source§

impl Interface for IFabricGetServiceListResult

Source§

impl Interface for IFabricGetServiceNameResult

Source§

impl Interface for IFabricGetServiceTypeListResult

Source§

impl Interface for IFabricGetUnplacedReplicaInformationResult

Source§

impl Interface for IFabricHealthClient2

Source§

impl Interface for IFabricHealthClient3

Source§

impl Interface for IFabricHealthClient4

Source§

impl Interface for IFabricHealthClient

Source§

impl Interface for IFabricInfrastructureServiceClient

Source§

impl Interface for IFabricMovePrimaryResult

Source§

impl Interface for IFabricMoveSecondaryResult

Source§

impl Interface for IFabricNameEnumerationResult

Source§

impl Interface for IFabricNetworkManagementClient

Source§

impl Interface for IFabricNodeHealthResult

Source§

impl Interface for IFabricNodeTransitionProgressResult

Source§

impl Interface for IFabricOrchestrationUpgradeStatusResult

Source§

impl Interface for IFabricPartitionDataLossProgressResult

Source§

impl Interface for IFabricPartitionHealthResult

Source§

impl Interface for IFabricPartitionQuorumLossProgressResult

Source§

impl Interface for IFabricPartitionRestartProgressResult

Source§

impl Interface for IFabricPropertyBatchResult

Source§

impl Interface for IFabricPropertyEnumerationResult

Source§

impl Interface for IFabricPropertyManagementClient2

Source§

impl Interface for IFabricPropertyManagementClient

Source§

impl Interface for IFabricPropertyMetadataResult

Source§

impl Interface for IFabricPropertyValueResult

Source§

impl Interface for IFabricQueryClient2

Source§

impl Interface for IFabricQueryClient3

Source§

impl Interface for IFabricQueryClient4

Source§

impl Interface for IFabricQueryClient5

Source§

impl Interface for IFabricQueryClient6

Source§

impl Interface for IFabricQueryClient7

Source§

impl Interface for IFabricQueryClient8

Source§

impl Interface for IFabricQueryClient9

Source§

impl Interface for IFabricQueryClient10

Source§

impl Interface for IFabricQueryClient

Source§

impl Interface for IFabricRepairManagementClient2

Source§

impl Interface for IFabricRepairManagementClient

Source§

impl Interface for IFabricReplicaHealthResult

Source§

impl Interface for IFabricResolvedServicePartitionResult

Source§

impl Interface for IFabricRestartDeployedCodePackageResult

Source§

impl Interface for IFabricRestartNodeResult

Source§

impl Interface for IFabricSecretReferencesResult

Source§

impl Interface for IFabricSecretStoreClient

Source§

impl Interface for IFabricSecretsResult

Source§

impl Interface for IFabricServiceDescriptionResult

Source§

impl Interface for IFabricServiceEndpointsVersion

Source§

impl Interface for IFabricServiceGroupDescriptionResult

Source§

impl Interface for IFabricServiceGroupManagementClient2

Source§

impl Interface for IFabricServiceGroupManagementClient3

Source§

impl Interface for IFabricServiceGroupManagementClient4

Source§

impl Interface for IFabricServiceGroupManagementClient

Source§

impl Interface for IFabricServiceHealthResult

Source§

impl Interface for IFabricServiceManagementClient2

Source§

impl Interface for IFabricServiceManagementClient3

Source§

impl Interface for IFabricServiceManagementClient4

Source§

impl Interface for IFabricServiceManagementClient5

Source§

impl Interface for IFabricServiceManagementClient6

Source§

impl Interface for IFabricServiceManagementClient

Source§

impl Interface for IFabricServiceNotification

Source§

impl Interface for IFabricServiceNotificationEventHandler

Source§

impl Interface for IFabricServicePartitionResolutionChangeHandler

Source§

impl Interface for IFabricStartNodeResult

Source§

impl Interface for IFabricStopNodeResult

Source§

impl Interface for IFabricTestCommandStatusResult

Source§

impl Interface for IFabricTestManagementClient2

Source§

impl Interface for IFabricTestManagementClient3

Source§

impl Interface for IFabricTestManagementClient4

Source§

impl Interface for IFabricTestManagementClient

Source§

impl Interface for IFabricUpgradeOrchestrationServiceStateResult

Source§

impl Interface for IFabricUpgradeProgressResult2

Source§

impl Interface for IFabricUpgradeProgressResult3

Source§

impl Interface for IFabricUpgradeProgressResult

Source§

impl Interface for IFabricAsyncOperationCallback

Source§

impl Interface for IFabricAsyncOperationContext

Source§

impl Interface for IFabricGetReplicatorStatusResult

Source§

impl Interface for IFabricStringListResult

Source§

impl Interface for IFabricStringResult

Source§

impl Interface for IFabricAtomicGroupStateProvider

Source§

impl Interface for IFabricAtomicGroupStateReplicator

Source§

impl Interface for IFabricCodePackage2

Source§

impl Interface for IFabricCodePackage

Source§

impl Interface for IFabricCodePackageActivationContext2

Source§

impl Interface for IFabricCodePackageActivationContext3

Source§

impl Interface for IFabricCodePackageActivationContext4

Source§

impl Interface for IFabricCodePackageActivationContext5

Source§

impl Interface for IFabricCodePackageActivationContext6

Source§

impl Interface for IFabricCodePackageActivationContext

Source§

impl Interface for IFabricCodePackageActivator

Source§

impl Interface for IFabricCodePackageChangeHandler

Source§

impl Interface for IFabricCodePackageEventHandler

Source§

impl Interface for IFabricConfigurationPackage2

Source§

impl Interface for IFabricConfigurationPackage

Source§

impl Interface for IFabricConfigurationPackageChangeHandler

Source§

impl Interface for IFabricDataPackage

Source§

impl Interface for IFabricDataPackageChangeHandler

Source§

impl Interface for IFabricEseLocalStoreSettingsResult

Source§

impl Interface for IFabricKeyValueStoreEnumerator2

Source§

impl Interface for IFabricKeyValueStoreEnumerator

Source§

impl Interface for IFabricKeyValueStoreItemEnumerator2

Source§

impl Interface for IFabricKeyValueStoreItemEnumerator

Source§

impl Interface for IFabricKeyValueStoreItemMetadataEnumerator2

Source§

impl Interface for IFabricKeyValueStoreItemMetadataEnumerator

Source§

impl Interface for IFabricKeyValueStoreItemMetadataResult

Source§

impl Interface for IFabricKeyValueStoreItemResult

Source§

impl Interface for IFabricKeyValueStoreNotification

Source§

impl Interface for IFabricKeyValueStoreNotificationEnumerator2

Source§

impl Interface for IFabricKeyValueStoreNotificationEnumerator

Source§

impl Interface for IFabricKeyValueStoreReplica2

Source§

impl Interface for IFabricKeyValueStoreReplica3

Source§

impl Interface for IFabricKeyValueStoreReplica4

Source§

impl Interface for IFabricKeyValueStoreReplica5

Source§

impl Interface for IFabricKeyValueStoreReplica6

Source§

impl Interface for IFabricKeyValueStoreReplica

Source§

impl Interface for IFabricNodeContextResult2

Source§

impl Interface for IFabricNodeContextResult

Source§

impl Interface for IFabricOperation

Source§

impl Interface for IFabricOperationData

Source§

impl Interface for IFabricOperationDataStream

Source§

impl Interface for IFabricOperationStream2

Source§

impl Interface for IFabricOperationStream

Source§

impl Interface for IFabricPrimaryReplicator

Source§

impl Interface for IFabricProcessExitHandler

Source§

impl Interface for IFabricReplicator

Source§

impl Interface for IFabricReplicatorCatchupSpecificQuorum

Source§

impl Interface for IFabricReplicatorSettingsResult

Source§

impl Interface for IFabricRuntime

Source§

impl Interface for IFabricSecondaryEventHandler

Source§

impl Interface for IFabricSecurityCredentialsResult

Source§

impl Interface for IFabricServiceGroupFactory

Source§

impl Interface for IFabricServiceGroupFactoryBuilder

Source§

impl Interface for IFabricServiceGroupPartition

Source§

impl Interface for IFabricStateProvider

Source§

impl Interface for IFabricStateReplicator2

Source§

impl Interface for IFabricStateReplicator

Source§

impl Interface for IFabricStatefulServiceFactory

Source§

impl Interface for IFabricStatefulServicePartition1

Source§

impl Interface for IFabricStatefulServicePartition2

Source§

impl Interface for IFabricStatefulServicePartition3

Source§

impl Interface for IFabricStatefulServicePartition

Source§

impl Interface for IFabricStatefulServiceReplica

Source§

impl Interface for IFabricStatelessServiceFactory

Source§

impl Interface for IFabricStatelessServiceInstance

Source§

impl Interface for IFabricStatelessServicePartition1

Source§

impl Interface for IFabricStatelessServicePartition2

Source§

impl Interface for IFabricStatelessServicePartition3

Source§

impl Interface for IFabricStatelessServicePartition

Source§

impl Interface for IFabricStoreEventHandler2

Source§

impl Interface for IFabricStoreEventHandler

Source§

impl Interface for IFabricStorePostBackupHandler

Source§

impl Interface for IFabricTransaction

Source§

impl Interface for IFabricTransactionBase

Implementors§