Learn R Programming

nanonext (version 0.10.4)

nextmode: Next Mode Settings

Description

Configures send mode 'next'. By registering 'refhook' functions for serialization and unserialization, allows sending and receiving reference objects, such as those accessed via an external pointer, between different R sessions.

Usage

nextmode(inhook, outhook, mark = FALSE)

Value

Invisibly, a pairlist comprising the currently-registered 'refhook' functions.

Arguments

inhook

a function (for custom serialization). The signature for this function must accept a list and return a raw vector, e.g. safetensors::safe_serialize, or else NULL to reset.

outhook

a function (for custom unserialization). The signature for this function must accept a raw vector and return a list, e.g. safetensors::safe_load_file, or else NULL to reset.

mark

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

Refhook

The 'refhook' functions are a native feature of R's serialization mechanism and apply to all non-system reference objects (external pointers, weak references, and all environments other than namespace and package environments and the Global Environment).

Details

Calling this function without any arguments returns (invisibly) the currently-registered 'refhook' functions (and resets 'mark' to FALSE).

Examples

Run this code
cfg <- nextmode(inhook = function(x) serialize(x, NULL),
                outhook = unserialize,
                mark = TRUE)
cfg

nextmode(NULL, NULL)
print(nextmode())

Run the code above in your browser using DataLab