pig/workspace

Types

Errors that can occur when working with a workspace.

pub type Error {
  SqlError(sqlight.Error)
  NotFound(path: String)
  NotEmpty(path: String)
  AlreadyExists(path: String)
  InvalidPath(path: String)
  KeyError(key: String)
}

Constructors

  • SqlError(sqlight.Error)
  • NotFound(path: String)
  • NotEmpty(path: String)
  • AlreadyExists(path: String)
  • InvalidPath(path: String)
  • KeyError(key: String)

The Workspace type wraps a SQLite connection.

pub opaque type Workspace

Values

pub fn all_tools(ws: Workspace) -> List(tool.Tool)

Get all workspace tools as a list.

pub fn close(ws: Workspace) -> Result(Nil, Error)

Close the workspace database.

pub fn connection(ws: Workspace) -> sqlight.Connection

Get the underlying connection (escape hatch for power users).

pub fn delete_file(
  ws: Workspace,
  path: String,
) -> Result(Nil, Error)

Delete a file or empty directory.

pub fn list_directory(
  ws: Workspace,
  path: String,
) -> Result(List(String), Error)

List entries in a directory.

pub fn list_keys(
  ws: Workspace,
  prefix: String,
) -> Result(List(String), Error)

List keys matching a prefix.

pub fn mkdir(ws: Workspace, path: String) -> Result(Nil, Error)

Create a directory.

pub fn open(path: String) -> Result(Workspace, Error)

Open a workspace database. Creates if doesn’t exist.

pub fn read_file(
  ws: Workspace,
  path: String,
) -> Result(String, Error)

Read the full content of a file.

pub fn read_file_lines(
  ws: Workspace,
  path: String,
  offset: Int,
  limit: Int,
) -> Result(String, Error)

Read lines with offset/limit, formatted with line numbers.

pub fn recall(
  ws: Workspace,
  key: String,
) -> Result(String, Error)

Retrieve a value by key.

pub fn remember(
  ws: Workspace,
  key: String,
  value: String,
) -> Result(Nil, Error)

Store a key-value pair.

pub fn write_file(
  ws: Workspace,
  path: String,
  content: String,
) -> Result(Nil, Error)

Write content to a file.

Search Document