OxL Reference

error not-serializable

error Standard: [§9.1]

What it means#

encode<T>, decode<T> and every other place that needs serialization (rpc parameters, topics, persisted actor fields) require T: Serializable. data and enum types are Serializable automatically when all their fields are; primitives, str, bytes, collections, tuples, T?, unions, distinct/refined types, time types, ActorRef<A> and secret<T> are too. Borrows, Rc, Arc, Task, stream, iter, functions, channels, Instant, String, ranges, interfaces and actors are not. The diagnostic names the offending component and the path to it.

Example#

oxl✓ checked in CI
use std.ser { encode }

data Shared {
  counter: Rc<i32>
}

fn dump(s: &Shared) {
  let b = encode(s)      // <- not-serializable
}
error
not-serializable

How to fix#

Replace the component with a serializable one (Rc<i32> with i32, String with str via freeze(), Instant with Time), or serialize a different type: a plain data copy of the persistent part. In a generic function add the bound: fn f<T: Serializable>(x: &T).

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides