Expand description
Serialization and deserialization of VMs
Texlang VMs can be serialized using the standard serde infrastructure
because they always satisfy the ::serde::Serialize
trait.
In the case when the VM’s state type implements super::HasDefaultBuiltInCommands
,
the VM satisfies the ::serde::Deserialize
trait too.
If the state type doesn’t implement this trait, deserialization is slightly more complicated because the set of built-in commands needs to be provided at deserialization time. This is because the built-in commands which are regular Rust functions, and it is not possible to fully serialize and deserialize Rust functions. Deserialization of VMs is thus a two-step process:
-
Deserialize the bytes to a
DeserializedVM
type. -
Invoke
finish_deserialization
with the deserialized VM and a map of built-in commands in order to recover the regular Texlang VM.
The Texlang VM has a deserialize_with_built_in_commands
convenience method
which performs both of these steps at once.
In the case when VM’s state type implements super::HasDefaultBuiltInCommands
,
the VM’s implementation of ::serde::Deserialize
handles all this automatically.
Structs
- A VM that has been deserialized.
Functions
- Finish the deserialization of a VM.