save_scan: Persist an observational snapshot to disk

View source: R/save_scan.R

save_scanR Documentation

Persist an observational snapshot to disk

Description

Saves a snapshot dataset (typically produced by scan_storage()) as a uniquely identified .rds file.

Usage

save_scan(df, storage_id, path, label = NULL)

Arguments

df

Data.frame. Scan result with created with scan_storage() that has a created_at attribute.

storage_id

Character. Identifier of the storage.

path

Character. Directory where the file will be saved.

label

Character. Optional human-readable label describing the scanned scope (e.g. "d_eviota"). Default is NULL (no label).

Details

The filename encodes:

  • storage context

  • observation time

  • optional scope label

  • a deterministic hash

This ensures:

  • chronological ordering

  • uniqueness

  • reproducibility of stored observations

Value

Invisibly returns the full file path of the saved .rds file.

Examples

tmp_dir <- tempfile()
dir.create(tmp_dir)

dir.create(file.path(tmp_dir, "R"))
dir.create(file.path(tmp_dir, "data"))

file.create(file.path(tmp_dir, "R", "a.R"))
file.create(file.path(tmp_dir, "R", "b.R"))
file.create(file.path(tmp_dir, "data", "c.csv"))

scan <- scan_storage(
  root = tmp_dir,
  storage_id = "test-storage"
)

save_scan(
  df = scan,
  storage_id = "test-storage",
  path = tmp_dir
)

fscontext documentation built on Nov. 19, 2026, 5:11 p.m.