Expand description
Structured-clone boundary between isolates (Phase B2).
serialize converts a Value to a Send + Sync intermediate form;
deserialize allocates a fresh copy into the current isolate’s GC heap.
Non-shareable values (mutable state, closures, native resources) produce a
CloneError so the compiler — not a runtime panic — enforces the boundary.
The round-trip is:
isolate A: Value → serialize → SerializedValue (Send) ──► thread boundary
isolate B: SerializedValue → deserialize → Value§What is shareable
- All scalar immediates:
Nil,Bool,Long,Double,Char,Uuid - Heap-allocated data values:
Str,BigInt,BigDecimal,Ratio,Pattern(source only),Symbol,Keyword - All persistent collections:
List,Vector,Map,Set,Queue,Cons - Primitive and object arrays (snapshot of current contents)
TypeInstancerecords (fields cloned recursively)Error(message + data + cause chain,Thrownvalue cloned recursively)- Lazy sequences: realized first; the realized value is then cloned
WithMeta,Reducedwrappers (inner value + meta cloned recursively)
§Cross-isolate shared references (Phase B3)
SharedAtom,ByteBlob—Arc-cloned, not deep-copied; both isolates share the same underlying cell/buffer.Var— the var’s root binding crosses through its shared cell (Arc<ArcSwap<Option<SharedValue>>>), so a vardef’d in one isolate is observable by value from another, keyword/symbol identity preserved. A var whose current root holds a non-promotable value (a closure / native resource) is not shareable and returnsCloneError— such vars are explicitly isolate-local (option (b) of the ADR).
§What is not shareable (returns CloneError)
Atom,Volatile,Promise,Future,Agent(mutable state)Fn,BoundFn,Macro,NativeFunction,ProtocolFn,MultiFn(closures capture isolate-localGcPtrs)Namespace,Protocol(global singletons managed elsewhere)Resource,NativeObject(isolate-bound OS handles / native objects)TransientMap,TransientSet,TransientVector(isolate-local transients)Delaywhose thunk has not yet been forced (thunk is isolate-local)Matcher(regex engine state tied to one execution context)
Structs§
- Serialized
Error - Serialized form of
crate::error::ExceptionInfo.
Enums§
- Clone
Error - Reason a value cannot cross an isolate boundary.
- Serialized
Error Kind - Mirrors
ValueErrorwithValuereplaced bySerializedValue. - Serialized
Value - Send + Sync intermediate form produced by
serializeand consumed bydeserialize. All heap data is owned (noGcPtr), so it is safe to move across thread boundaries.
Functions§
- deserialize
- Deserialize a wire form into a fresh
Valueallocated in the current isolate’s GC heap. Infallible: all non-shareable values are rejected atserializetime, so nothing inSerializedValuerequires runtime checks. - serialize
- Serialize a
Valueinto aSend + Syncwire form suitable for crossing an isolate boundary. ReturnsCloneErrorfor non-shareable values.