Skip to main content

WitBoundary

Trait WitBoundary 

Source
pub trait WitBoundary: Sized {
    type Wit;

    // Required methods
    fn to_wit(&self) -> Result<Self::Wit, String>;
    fn from_wit(wit: Self::Wit) -> Result<Self, String>;
}
Expand description

Converts a native host type to/from its generated WIT mirror.

to_wit borrows the native value (the host owns it); from_wit consumes the WIT value (it arrived by value across the boundary). Both return Result<_, String> — the WIT result<_, string> convention — so a value that cannot be represented in the current WIT surface is a typed error, not a panic or a silent drop.

Required Associated Types§

Source

type Wit

The generated WIT mirror type.

Required Methods§

Source

fn to_wit(&self) -> Result<Self::Wit, String>

Project the native value into its owned WIT mirror.

Source

fn from_wit(wit: Self::Wit) -> Result<Self, String>

Reconstruct the native value from its WIT mirror.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl WitBoundary for Annotation

Source§

impl WitBoundary for AppEffect

Source§

impl WitBoundary for AppliedEdit

Source§

impl WitBoundary for AppliedEdit

Source§

impl WitBoundary for ArgDefault

Source§

impl WitBoundary for ArgKind

Source§

impl WitBoundary for ArgSpec

Source§

impl WitBoundary for ArgValue

Source§

impl WitBoundary for Args

Source§

impl WitBoundary for CandidateData

Source§

impl WitBoundary for CandidateKind

Source§

impl WitBoundary for ContextScope

Source§

impl WitBoundary for EchoLevel

Source§

impl WitBoundary for Edit

Source§

impl WitBoundary for EditDelta

Source§

impl WitBoundary for EditKind

Source§

impl WitBoundary for Effect

Source§

type Wit = Vec<Effect>

Effect is recursive (Many(Vec<Effect>)), which WIT value types cannot express. The boundary crosses a list<effect> instead: a single effect is a one-element list, and Many (associative composition) is flattened. from_wit rebuilds Many when the list has more than one element; an empty list is Effect::None. A single-element Many([x]) therefore normalises to x — a semantic identity, since Many([x]) ≡ x.

Source§

fn to_wit(&self) -> Result<Vec<WitEffect>, String>

Source§

fn from_wit(wit: Vec<WitEffect>) -> Result<Self, String>

Source§

impl WitBoundary for Event

Source§

fn to_wit(&self) -> Result<WitEvent, String>

Compiler-exhaustive: a new Event arm forces a mapping here. Ids cross as u64 (.raw()); paths via path_to_wit (non-UTF-8 → typed error).

Source§

type Wit = Event

Source§

fn from_wit(wit: WitEvent) -> Result<Self, String>

Source§

impl WitBoundary for EventKind

Source§

impl WitBoundary for GutterDecoration

Source§

fn to_wit(&self) -> Result<WitGutterDecoration, String>

SG.4b: every native decoration is a Sign now, and a sign carries an interned id whose NAME only the registry knows. This context-free conversion does not have one, so both directions refuse by naming the registry-aware pair rather than dropping the placement.

The impl is kept rather than deleted because it is what makes that refusal a compiler-checked total function: a future arm still has to decide here, and “needs a registry” is a decision worth being told about rather than discovered as a missing glyph.

Source§

type Wit = GutterDecoration

Source§

fn from_wit(wit: WitGutterDecoration) -> Result<Self, String>

Source§

impl WitBoundary for GutterDiffKind

Source§

impl WitBoundary for GutterSeverityLevel

Source§

impl WitBoundary for HScroll

Source§

impl WitBoundary for InsertLineEdit

Source§

impl WitBoundary for KeyChord

Source§

impl WitBoundary for LatencyClass

Intern a plugin-supplied owned string as &'static str. SurfaceForm’s

Source§

impl WitBoundary for LspRequest

Source§

impl WitBoundary for ModalState

Source§

impl WitBoundary for MotionResult

Source§

impl WitBoundary for OpenTarget

Source§

impl WitBoundary for PaneDirection

Source§

impl WitBoundary for PickerAcceptOutcome

Source§

impl WitBoundary for PickerSourceSpec

Source§

impl WitBoundary for Position

Source§

impl WitBoundary for QuitScope

Source§

impl WitBoundary for Range

Source§

impl WitBoundary for RawCandidate

Source§

impl WitBoundary for Register

Source§

impl WitBoundary for RoutingPayload

Source§

impl WitBoundary for ScrollPos

Source§

impl WitBoundary for SearchDirection

Source§

impl WitBoundary for Selection

Source§

impl WitBoundary for SelectionSet

Source§

impl WitBoundary for SpecialKey

Source§

impl WitBoundary for SubstituteScope

Source§

impl WitBoundary for SurfaceForm

Source§

impl WitBoundary for Utf16Pos

Source§

impl WitBoundary for ViewportPos

Source§

impl WitBoundary for VisualKind

Source§

impl WitBoundary for VisualMode

Source§

impl WitBoundary for YankKind

Implementors§