Silk

silk/toml_codec

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.

Static contracts for converting common Silk values to and from TOML values.

When to use

Use TomlCodec.writeOne to write a typed value after a key and separator. Use TomlCodec.decodeOne on a parsed value for allocation-free types, or TomlCodec.deserializeOne for an owned string.

Import as TomlCodec with import silk.toml_codec { TomlCodec }.

Public declarations: 4.

Serialize

pub interface Serialize

A type that writes one TOML value through the ambient Writer.

Operation serialize

effect<'life0> fn serialize<'life0>(self: &'life0 Self) -> () ! TomlError | WriterError ? &mut Writer

Writes one value in TOML syntax through the ambient Writer.

Decode

pub interface Decode

A type decoded from an owned TOML value without allocation.

Operation decode

fn decode<'life0>(value: &'life0 silk/toml_value.Value) -> silk/result.Result<Self, silk/toml_scanner.TomlError>

Converts one owned TOML value without allocation or returns a typed failure.

Deserialize

pub interface Deserialize

A type decoded from an owned TOML value with allocation.

Operation deserialize

effect<'life0> fn deserialize<'life0>(value: &'life0 silk/toml_value.Value) -> Self ! TomlError | OutOfMemoryError ? &mut Allocator

Converts one owned TOML value with the ambient allocator.

TomlCodec

pub struct TomlCodec

Selects static TOML conversion witnesses.

Associated function TomlCodec.writeOne

pub effect<'life1> fn writeOne<T: 'life1, 'life1>(value: &'life1 T) -> () ! TomlError | WriterError ? &mut Writer

Writes a typed value in value position through the ambient Writer.

Gotchas

Write the key and = before this call when writing a document.

Associated function TomlCodec.decodeOne

pub fn decodeOne<T, 'life1>(value: &'life1 silk/toml_value.Value) -> silk/result.Result<T, silk/toml_scanner.TomlError>

Decodes an allocation-free type from one owned value, or returns a typed failure.

Associated function TomlCodec.deserializeOne

pub effect<'life1> fn deserializeOne<T, 'life1>(value: &'life1 silk/toml_value.Value) -> T ! TomlError | OutOfMemoryError ? &mut Allocator

Deserializes an allocating type from one owned value with the ambient allocator.

Implementation Serialize for bool

impl Serialize for bool

Operation serialize

serialize = bool.impl@1.serialize

Implementation Decode for bool

impl Decode for bool

Operation decode

decode = bool.impl@2.decode

Implementation Serialize for i64

impl Serialize for i64

Operation serialize

serialize = i64.impl@3.serialize

Implementation Decode for i64

impl Decode for i64

Operation decode

decode = i64.impl@4.decode

Implementation Serialize for i32

impl Serialize for i32

Operation serialize

serialize = i32.impl@5.serialize

Implementation Decode for i32

impl Decode for i32

Operation decode

decode = i32.impl@6.decode

Implementation Serialize for f64

impl Serialize for f64

Operation serialize

serialize = f64.impl@7.serialize

Implementation Deserialize for f64

impl Deserialize for f64

Operation deserialize

deserialize = f64.impl@8.deserialize

Implementation Serialize for string<'a>

impl Serialize for string<'a>

Operation serialize

serialize = string.impl@9.serialize

Implementation Serialize for String

impl Serialize for String

Operation serialize

serialize = String.impl@10.serialize

Implementation Deserialize for String

impl Deserialize for String

Operation deserialize

deserialize = String.impl@11.deserialize

On this page