Skip to main content

Codec

Trait Codec 

Source
pub trait Codec {
    type Rust;

    // Required methods
    fn to_lean(value: &Self::Rust) -> Obj;
    unsafe fn from_lean(object: Obj) -> Self::Rust;
}
Expand description

A conversion between a Rust type and the Lean type the implementor stands for.

Required Associated Types§

Required Methods§

Source

fn to_lean(value: &Self::Rust) -> Obj

A new Lean object with the value, owned by the caller.

Source

unsafe fn from_lean(object: Obj) -> Self::Rust

Reads the value out of object and gives up one reference to it.

§Safety

object must be a value of the Lean type this codec stands for, produced by this runtime, and the caller must own a reference to it.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Codec for ByteArray

Source§

impl Codec for FloatArray

Source§

impl<A: Codec, B: Codec> Codec for Pair<A, B>

Source§

type Rust = (<A as Codec>::Rust, <B as Codec>::Rust)

Source§

impl<C: Codec> Codec for Array<C>

Source§

type Rust = Vec<<C as Codec>::Rust>

Source§

impl<C: Codec> Codec for Boxed<C>

Source§

type Rust = Box<<C as Codec>::Rust>

Source§

impl<C: Codec> Codec for List<C>

Source§

type Rust = Vec<<C as Codec>::Rust>

Source§

impl<C: Codec> Codec for Option<C>

Source§

type Rust = Option<<C as Codec>::Rust>

Source§

impl<E: Codec, A: Codec> Codec for Except<E, A>

Source§

type Rust = Result<<A as Codec>::Rust, <E as Codec>::Rust>

Source§

impl<T: ToLean + FromLean> Codec for Plain<T>

Source§

type Rust = T