serial_config: Create Serialization Configuration

View source: R/sakura.R

serial_configR Documentation

Create Serialization Configuration

Description

Returns a serialization configuration for custom serialization and unserialization of non-system reference objects, using the 'refhook' system of R native serialization. This allows their use across different R sessions.

Usage

serial_config(class, sfunc, ufunc, vec = FALSE)

Arguments

class

character string of the class of object custom serialization functions are applied to, e.g. ‘ArrowTabular’ or ‘torch_tensor’.

sfunc

a function that accepts a reference object inheriting from ‘class’ (or a list of such objects) and returns a raw vector.

ufunc

a function that accepts a raw vector and returns a reference object (or list of such objects).

vec

[default FALSE] whether or not the serialization functions are vectorized. If FALSE, they should accept and return reference objects individually e.g. arrow::write_to_raw and arrow::read_ipc_stream. If TRUE, they should accept and return a list of reference objects, e.g. torch::torch_serialize and torch::torch_load.

Value

A pairlist comprising the configuration. This may be provided to the 'hook' argument of serialize and unserialize.

Examples

serial_config("test_class", base::serialize, base::unserialize)


sakura documentation built on April 3, 2025, 7:46 p.m.