Skip to main content

SurfaceCodec

Trait SurfaceCodec 

Source
pub trait SurfaceCodec: Send + Sync {
    // Required methods
    fn encode(
        &self,
        cx: &mut Cx,
        value: &Expr,
        caps: &SurfaceCaps,
    ) -> Result<Expr>;
    fn decode(&self, cx: &mut Cx, value: &Expr, intent: &Expr) -> Result<Draft>;
    fn commit(&self, cx: &mut Cx, draft: &Draft) -> Result<Operation>;
}
Expand description

One reversible surface codec: encode a value to a projected Scene, decode an Intent to a Draft, and commit a Draft to a checked Operation.

Implementors back both directions with one definition. PairCodec adapts a legacy (View, Editor) pair to this contract.

Required Methods§

Source

fn encode(&self, cx: &mut Cx, value: &Expr, caps: &SurfaceCaps) -> Result<Expr>

Renders value to a Scene projected for caps (deterministic).

Source

fn decode(&self, cx: &mut Cx, value: &Expr, intent: &Expr) -> Result<Draft>

Decodes intent against value into a previewable Draft.

Source

fn commit(&self, cx: &mut Cx, draft: &Draft) -> Result<Operation>

Commits a committable Draft into a checked Operation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§