Skip to main content

Positivity

Trait Positivity 

Source
pub trait Positivity: Sealed {
    type NegativeOfThis: Positivity<NegativeOfThis = Self>;
    type CallResult<T>;
    type Borrow<'a, T: 'a>;
}
Expand description

Whether an instance/resource/etc is being used in a positive or negative position in the top-level component type that governs the interface. That is to say, whether the functions provided by this instance/resource (or exported by this component) are expected to be implemented in the guest and called on the host or vice versa.

We say that a piece of a top-level component type is in “negative position” if it is on the left hand side of an odd number of arrows, and positive otherwise. With only first-order component types, this distinction collapses to whether it is part of an import (negative) or export (positive), but with higher-order components, this is no longer the case. For example, if a component imports another component which itself imports some functions, those functions are in positive position in the overall type—because they are supplied by the guest when it instantiates the component it imported—even though they are syntactically imports.

Required Associated Types§

Source

type NegativeOfThis: Positivity<NegativeOfThis = Self>

Source

type CallResult<T>

How a call to one of the interface’s functions returns.

Source

type Borrow<'a, T: 'a>

How a borrowed resource handle reaches the implementation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§