Expand description
Serialization and deserialization of VMs
Texcraft’s documentation website has a dedicated page about serializing and deserializing VMs. The documentation here is for reference.
§Serialization
If the state type S implements ::serde::Serialize then
the Texlang VM vm::V<S> satisfies the ::serde::Serialize trait too.
VMs can thus be serialized using the standard Serde infrastructure.
§Deserialization
If the state S implements ::serde::Deserialize and
the Texlang trait super::HasDefaultBuiltInCommands,
the Texlang VM vm::V<S> satisfies the ::serde::Deserialize trait too.
If the state doesn’t implement the Texlang trait, deserialization is slightly more complicated because the set of built-in primitives needs to be provided at deserialization time. This is because the built-in primitives 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
DeserializedVMtype. -
Invoke
finish_deserializationwith 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.
Structs§
- A VM that has been deserialized.
Functions§
- Finish the deserialization of a VM.