def source.opened

mylsm-lsm-store@0.6.0.1 · src/transfer/RestoreIo.bend:475

import mylsm-lsm-store@0.6.0.1/src/transfer/RestoreIo.bend as RestoreIo
import Base
import mylsm-lsm-store@0.6.0.1/src/Fs.bend as Fs
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

475def source.opened(
476  +destination: String,
477  +size: Nat,
478  opened: Result<&1, &1, U32 & String, File>
479) -> IO(Result<&1, &1, Error, Unit>):
480  match opened:
481    case Fail{(code, message)}:
482      IO.pure(Result<&1, &1, Error, Unit>, Fail{Io{code, message}})
483    case Done{file}:
484      do IO<Result<&1, &1, Error, Unit>>:
485        pair : File & Result<&1, &1, U32 & String, Bytes.Bytes> <-
486          Fs.read_at(file, 0, U32.from_nat(size))
487        source.read.result(destination, size, pair)

Uses (16)

Used by (1)