IF Commons GitHub

physical/state

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-netboot-physical FR-001

The state of the boot server kept in a file, so that an arming survives the server and a person can arm a host while the server runs. A write is a new file moved over the old one, so that a reader never sees half of it.

import { readState } from "./state.ts";
// (await readState("/var/lib/netboot/state.json")).armed

Source: commons/netboot/src/physical/state.ts

2 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.readStatefunctionno test imports it
function readState(file: string): Promise<BootState>

The state in a file (the empty state where there is no file or it is not readable as state).

physical.writeStatefunctionno test imports it
function writeState(file: string, state: BootState): Promise<void>

Writes the state, replacing the file whole.

physical.updateStatefunctionno test imports it
function updateState<T>(file: string, f: (s: BootState) => { readonly state: BootState; readonly value: T; }): Promise<T>

Reads the state, changes it with f and writes it back, one change at a time.

readStatefunction
function readState(file: string): Promise<BootState>

The state in a file (the empty state where there is no file or it is not readable as state).

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

writeStatefunctionno test imports it
function writeState(file: string, state: BootState): Promise<void>

Writes the state, replacing the file whole.

updateStatefunction
function updateState<T>(file: string, f: (s: BootState) => { readonly state: BootState; readonly value: T; }): Promise<T>

Reads the state, changes it with f and writes it back, one change at a time.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.