RApiSerialize-package.RdThis package provides other packages with access to the internal R serialization code. Access is provided at the C function level via the registered function facility
For convenience and testing purposes, two wrapper functions are also provided at the R level.
serializeToRaw(obj, version=2, xdr=TRUE)
unserializeFromRaw(obj)An R object which is going to (un)serialized by the corresponding function.
An integer selection the R serialization format. Default is 2, and values 2 or 3 are currently supported.
A logical value selection (portable) XDR encoding which is the
default. Use FALSE for speed-up suitable for common little-endian
system at a loss of portability.
The C code in this package is taken from R source code, where it provided for use by R only in a way that renders it inaccessible to other packages.
This package aims to fill this gap by providing access to the same functionality, at the cost of making a copy.
To use the serialization and deserialization code provided here, a
client package simply adds LinkingTo: RApiSerialize in its
DESCRIPTION file and includes the header file
RApiSerializeAPI.h.
The R source code in src/main/serialize.c.
## calling the R wrapper
serializeToRaw(letters)
#> [1] 58 0a 00 00 00 02 00 04 05 01 00 02 03 00 00 00 00 10 00 00 00 1a 00 04 00
#> [26] 09 00 00 00 01 61 00 04 00 09 00 00 00 01 62 00 04 00 09 00 00 00 01 63 00
#> [51] 04 00 09 00 00 00 01 64 00 04 00 09 00 00 00 01 65 00 04 00 09 00 00 00 01
#> [76] 66 00 04 00 09 00 00 00 01 67 00 04 00 09 00 00 00 01 68 00 04 00 09 00 00
#> [101] 00 01 69 00 04 00 09 00 00 00 01 6a 00 04 00 09 00 00 00 01 6b 00 04 00 09
#> [126] 00 00 00 01 6c 00 04 00 09 00 00 00 01 6d 00 04 00 09 00 00 00 01 6e 00 04
#> [151] 00 09 00 00 00 01 6f 00 04 00 09 00 00 00 01 70 00 04 00 09 00 00 00 01 71
#> [176] 00 04 00 09 00 00 00 01 72 00 04 00 09 00 00 00 01 73 00 04 00 09 00 00 00
#> [201] 01 74 00 04 00 09 00 00 00 01 75 00 04 00 09 00 00 00 01 76 00 04 00 09 00
#> [226] 00 00 01 77 00 04 00 09 00 00 00 01 78 00 04 00 09 00 00 00 01 79 00 04 00
#> [251] 09 00 00 00 01 7a