serialization {mirai} | R Documentation |
Custom Serialization Functions
Description
Registers custom serialization and unserialization functions for sending and receiving reference objects.
Usage
serialization(fns, class, vec = FALSE)
Arguments
fns |
either a list comprising 2 functions: |
class |
the class of reference object (as a character string) that these functions are applied to, e.g. 'ArrowTabular' or 'torch_tensor'. |
vec |
[default FALSE] if FALSE the functions must accept and return
reference objects individually e.g. |
Details
Registering new functions replaces any existing registered functions.
This function may be called prior to or after setting daemons, with the registered functions applying across all compute profiles.
Calling without any arguments returns a list comprising the registered values for 'fns', class', and 'vec', or else NULL if not registered.
Value
Invisibly, a list comprising 'fns', class', and 'vec', or else NULL if supplied to 'fns'.
Examples
reg <- serialization(
list(function(x) serialize(x, NULL), base::unserialize),
class = "example_class"
)
reg
serialization(NULL)
print(serialization())