r8write_rds() writes an RDS file that ends in the SHA-256 of its content, and
r8read_rds() compares the two before R reads the object. readRDS() reads
the file too.
Arguments
- x
An object: an R8 value, or any other.
- file
Character: The path of the file.
- compress
Logical or Character {"gzip", "bzip2", "xz"}: The compression, as that of
saveRDS().
Value
r8write_rds(): file, invisibly. r8read_rds(): The object. A file
that is damaged, or that r8write_rds() did not write, raises r8_file_error.
Details
R reads a serialized object without a check: a file that a disk or a transfer
damaged gives another object, an error of R's own, or a crash of the session.
r8read_rds() raises an error that names the file.
Examples
op <- options(r8.namespace = "demo")
Point <- new_struct("Point", fields = list(x = type_double(), y = type_double()))
file <- tempfile(fileext = ".rds")
r8write_rds(Point(x = 1, y = 2), file)
r8read_rds(file)#> <demo::Point>
#> x: 1
#> y: 2