#[repr(C)]pub enum HttpOutcome {
Response {
status: u16,
headers: Vec<HttpHeader>,
body: Vec<u8>,
},
TransportError {
message: String,
},
}Expand description
The result of an HTTP request.
Variants§
Response
The server answered. status is the real HTTP status — 409 is distinguishable
from 500.
TransportError
No HTTP response was obtained, for any reason: chiefly network failure (offline, DNS, TLS, connection refused, timeout), but also a request that could not be attempted at all (unknown verb, malformed envelope). The defining property is that the server never answered, so no status exists.
Implementations§
Source§impl HttpOutcome
impl HttpOutcome
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
True only for a 2xx response.
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
The body as text, or None if it is not valid UTF-8 or this is a
TransportError (which has no body at all). An empty-but-present body
returns Some(""), not None.
Sourcepub fn header(&self, name: &str) -> Option<&str>
pub fn header(&self, name: &str) -> Option<&str>
Look up a response header by name, case-insensitively.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Serialize for transport in PluginResponse.output.
Uses crux’s own FFI format rather than calling bincode directly. This is not
incidental: crux pins bincode =1.3 with with_fixint_encoding(), whereas
bincode 2.x’s config::standard() is varint. The two produce different
bytes, and the Swift/Kotlin decoders generated by serde-generate expect crux’s
encoding — so hand-rolling this would silently yield garbage across the FFI.