R/serialization.R

Defines functions serialize_write serialize_read_syntax serialize_read

serialize_read <- function(path, format) {
  switch(format,
         rds = readRDS(file = path),
         qs = qs::qread(file = path, strict = TRUE)
  )
}

serialize_read_syntax <- function(format) {
  switch(format,
         rds = "readRDS",
         qs = "qs::qread")
}

serialize_write <- function(object, path, format) {
  switch(format,
         rds = saveRDS(object = object, file = path),
         qs = qs::qsave(x = object, file = path)
  )
}

Try the saros.base package in your browser

Any scripts or data that you put into this service are public.

saros.base documentation built on June 8, 2025, 10:03 a.m.