def bytes_of

mlbend-huggingface@0.1.1.0 · main.bend:92

import mlbend-huggingface@0.1.1.0/main.bend as MlbendHuggingface
import Base
import bend-kit-http@0.36.0.0/http.bend as Http
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

92# The bytes of a response, or the reason there are none.
93def bytes_of(r: Result<&1, &1, Http.Err, Http.Res>) -> Result<&1, &1, Err, Bytes.Bytes>:
94  match r:
95    case Fail{e}:
96      Fail{why_of(e)}
97    case Done{Http.Res{+status, headers, body}}:
98      Bool.pick(Result<&1, &1, Err, Bytes.Bytes>, U32.is_lt(status, 400),
99        Done{body},
100        Fail{ErrStatus{status}})

Uses (8)

Used by (1)