~/bend-docscommunity

src/hub/hub.bend checks

raw source on the hub · import ezx@1.15.0.0/src/hub/hub.bend as Hub

hub/hub: a file fetched from the hub, and checked against the hash that names it. bend accepts any prefix of the sha256, and a package's 0x name is the first 32 characters of its manifest's digest, so the check is a prefix test.

Trusted, not proved: the hub serves, for a hash, what was published under it. ez checks every hub body against the hash it asked for (laws/FetchLaysTheLock.bend), so this comes down to the hub being there and to Sha.hex being SHA-256 (trusted in share/sha.bend).

2 imports
import Base
import ../share/sha.bend as Sha

Types

type Got source · line 39 · raw

Data

what a fetch answered: the body when it arrived and hashed right, otherwise the reason, so a caller never mistakes an error page for a package file

Definitions

def get.status source · line 17 · raw

@ok:Bool -> @status:U32 -> @body:String -> String

a status other than 200 is a miss with the number in it, never a body

def get.file.got source · line 26 · raw

@got:Maybe<&2, String> -> @path:String -> String

a file url read off the disk. curl served these too, and a test that wants a body without a server to serve it is the reason to keep them.

def matches source · line 34 · raw

@want:String -> @+body:String -> Bool

a body is the one that was asked for when its digest starts with the hash

def judge.hash source · line 44 · raw

@good:Bool -> @url:String -> @body:String -> Got

the digest's verdict on a body that did arrive

def judge source · line 52 · raw

@ok:Bool -> @good:Bool -> @url:String -> @body:String -> Got

a fetch judged, once the run and the digest are both known

def show source · line 60 · raw

@got:Got -> String

a fetch's outcome on one line