Configures send mode ‘next’ by registering functions for custom serialization and unserialization of non-system reference objects, allowing these to be sent and received between different R sessions.

next_config(refhook = list(), class = "", vec = FALSE, mark = FALSE)

Arguments

refhook

either a list or pairlist of two functions: the signature for the first must accept a reference object inheriting from ‘class’ (or a list of such objects) and return a raw vector, and the second must accept a raw vector and return reference objects (or a list of such objects),
or else NULL to reset.

class

[default ""] a character string representing the class of object that these serialization function will be applied to, e.g. ‘ArrowTabular’ or ‘torch_tensor’.

vec

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

mark

[default FALSE] (for advanced use only) logical value, whether to mark serialized data with a special bit.

Value

A pairlist comprising the currently-registered ‘refhook’

functions.

Details

Calling this function without any arguments returns the pairlist of currently-registered ‘refhook’ functions (and resets ‘mark’ to FALSE).

Examples

g <- next_config(refhook = list(function(x) serialize(x, NULL), unserialize))
next_config()
#> [[1]]
#> function(x) serialize(x, NULL)
#> <environment: 0x55bcee6fa4d8>
#> 
#> [[2]]
#> function (connection, refhook = NULL) 
#> {
#>     if (typeof(connection) != "raw" && !is.character(connection) && 
#>         !inherits(connection, "connection")) 
#>         stop("'connection' must be a connection")
#>     .Internal(unserialize(connection, refhook))
#> }
#> <bytecode: 0x55bcee74c2b8>
#> <environment: namespace:base>
#> 
next_config(g, mark = TRUE)
#> [[1]]
#> function(x) serialize(x, NULL)
#> <environment: 0x55bcee6fa4d8>
#> 
#> [[2]]
#> function (connection, refhook = NULL) 
#> {
#>     if (typeof(connection) != "raw" && !is.character(connection) && 
#>         !inherits(connection, "connection")) 
#>         stop("'connection' must be a connection")
#>     .Internal(unserialize(connection, refhook))
#> }
#> <bytecode: 0x55bcee74c2b8>
#> <environment: namespace:base>
#> 

next_config(NULL)
#> [[1]]
#> NULL
#> 
#> [[2]]
#> NULL
#> 
next_config()
#> [[1]]
#> NULL
#> 
#> [[2]]
#> NULL
#>