def open

bend-kit-journal@0.3.1.0 · journal.bend:348

import bend-kit-journal@0.3.1.0/journal.bend as Journal
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

348# Opens the journal at path and folds step over its committed records, from acc.
349# A torn tail is cut off and fsynced before open answers. A corrupt frame fails with EINVAL and
350# its offset; the file is left as it is. max caps a record's length; limit caps the file's size.
351def open(~A: Type, ~step: A -> Bytes.Bytes -> A, path: String, +max: U32, limit: U32, acc: A) -> IO(Result<&1, &1, U32 & String, Journal & A>):
352  do IO<Result<&1, &1, U32 & String, Journal & A>>:
353    r : Result<&1, &1, U32 & String, File & U32 & Array<U32>> <- open.words(path, limit)
354    open.read(~A, ~step, r, max, acc)

Uses (12)

Used by (3)