def St.length
bendtorch-load@1.3.0.0 · main.bend:550
import bendtorch-load@1.3.0.0/main.bend as BendtorchLoad
import Base
550
551def St.length(f: File, +path: String, h: Maybe<&2, W64>) -> IO(Header):
552 match h:
553 case None{}: IO.die(Header, 1, path ++ ": shorter than a safetensors header")
554 case Some{W64{hi, +lo}}:
555 do IO<Header>:
556 require(Bool.and(U32.is_zero(hi), U32.is_le(lo, 100000000)), path ++ ": a safetensors header past 100 MB")
557 r : File & Result<&1, &1, U32 & String, List<&2, U32>> <- File.read_at(f, 8, lo)
558 St.header(path, lo, r)