src/hub/hub.bend checks
raw source on the hub · import 0x886223f5c47e4983fe57d887c034bc7f/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.
2 imports
import Base import ../share/sha.bend as Sha
Types
type Got source · line 34 · 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
Miss@why:String -> Got
Have@body:String -> Got
Definitions
def get.status source · line 12 · 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 21 · 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 29 · 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 39 · raw
@good:Bool -> @url:String -> @body:String -> Got
the digest's verdict on a body that did arrive
def judge source · line 47 · 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 55 · raw
@got:Got -> String
a fetch's outcome on one line