Debian Codegraph @

man/serial_config.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/utils.R
3 \name{serial_config}
4 \alias{serial_config}
5 \title{Create Serialization Configuration}
6 \usage{
7 serial_config(class, sfunc, ufunc)
8 }
9 \arguments{
10 \item{class}{a character string (or vector) of the class of object custom
11 serialization functions are applied to, e.g. \code{'ArrowTabular'} or
12 \code{c('torch_tensor', 'ArrowTabular')}.}
13
14 \item{sfunc}{a function (or list of functions) that accepts a reference
15 object inheriting from \code{class} and returns a raw vector.}
16
17 \item{ufunc}{a function (or list of functions) that accepts a raw vector and
18 returns a reference object.}
19 }
20 \value{
21 A list comprising the configuration. This should be set on a Socket
22 using \code{\link[=opt<-]{opt<-()}} with option name \code{"serial"}.
23 }
24 \description{
25 Returns a serialization configuration, which may be set on a Socket for
26 custom serialization and unserialization of non-system reference objects,
27 allowing these to be sent and received between different R sessions. Once
28 set, the functions apply to all send and receive operations performed in mode
29 'serial' over the Socket, or Context created from the Socket.
30 }
31 \details{
32 This feature utilises the 'refhook' system of R native serialization.
33 }
34 \examples{
35 cfg <- serial_config("test_cls", function(x) serialize(x, NULL), unserialize)
36 cfg
37
38 cfg <- serial_config(
39 c("class_one", "class_two"),
40 list(function(x) serialize(x, NULL), function(x) serialize(x, NULL)),
41 list(unserialize, unserialize)
42 )
43 cfg
44
45 s <- socket()
46 opt(s, "serial") <- cfg
47
48 # provide an empty list to remove registered functions
49 opt(s, "serial") <- list()
50
51 close(s)
52
53 }