slate

Types

Access mode for opening tables.

pub type AccessMode {
  ReadWrite
  ReadOnly
}

Constructors

  • ReadWrite

    Read and write access (default)

  • ReadOnly

    Read-only access — writes will return AccessDenied

Errors that can occur during DETS operations.

pub type DetsError {
  NotFound
  FileNotFound
  AlreadyOpen
  TableDoesNotExist
  FileSizeLimitExceeded
  KeyAlreadyPresent
  AccessDenied
  TypeMismatch
  TableNamePoolExhausted
  DecodeErrors(List(decode.DecodeError))
  ErlangError(String)
}

Constructors

  • NotFound

    No value found for the given key

  • FileNotFound

    Table file does not exist (when opening without create)

  • AlreadyOpen

    Table is already open with a different configuration

  • TableDoesNotExist

    The table does not exist (not open)

  • FileSizeLimitExceeded

    File exceeds the 2 GB DETS limit

  • KeyAlreadyPresent

    Key already exists (for insert_new)

  • AccessDenied

    Write operation attempted on a read-only table

  • TypeMismatch

    Table type mismatch (e.g., opening a set file as a bag)

  • TableNamePoolExhausted

    All internal table name slots are in use; close unused tables to free slots

  • DecodeErrors(List(decode.DecodeError))

    Data read from disk did not match the expected Gleam types

  • ErlangError(String)

    Erlang-level error (catch-all)

DETS table type.

pub type Kind {
  Set
  Bag
  DuplicateBag
}

Constructors

  • Set

    One value per key (default)

  • Bag

    Multiple distinct values per key

  • DuplicateBag

    Multiple values per key, duplicates allowed

Auto-repair policy for improperly closed tables.

pub type RepairPolicy {
  AutoRepair
  ForceRepair
  NoRepair
}

Constructors

  • AutoRepair

    Repair automatically if needed (default)

  • ForceRepair

    Force repair even if file appears clean

  • NoRepair

    Don’t repair, return error instead

Information about an open DETS table.

pub type TableInfo {
  TableInfo(file_size: Int, object_count: Int, kind: Kind)
}

Constructors

  • TableInfo(file_size: Int, object_count: Int, kind: Kind)

Values

pub fn is_dets_file(path: String) -> Result(Bool, DetsError)

Check whether the given file is a valid DETS file.

Returns Ok(True) if the file is a valid DETS file, Ok(False) if it exists but is not a DETS file, or an error if the file cannot be read.

let assert Ok(True) = slate.is_dets_file("data/cache.dets")
let assert Ok(False) = slate.is_dets_file("README.md")
Search Document