Skip to main content

HttpOutcome

Enum HttpOutcome 

Source
#[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.

Fields

§status: u16
§headers: Vec<HttpHeader>
§body: Vec<u8>
§

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.

Fields

§message: String

Implementations§

Source§

impl HttpOutcome

Source

pub fn status(&self) -> Option<u16>

The HTTP status, or None when the server never answered.

Source

pub fn is_success(&self) -> bool

True only for a 2xx response.

Source

pub fn body(&self) -> &[u8]

The raw response body; empty for a transport error.

Source

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.

Source

pub fn header(&self, name: &str) -> Option<&str>

Look up a response header by name, case-insensitively.

Source

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.

Source

pub fn decode(bytes: &[u8]) -> Result<Self, String>

Decode what a shell placed in PluginResponse.output.

Trait Implementations§

Source§

impl Clone for HttpOutcome

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpOutcome

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for HttpOutcome

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for HttpOutcome

Source§

impl<'ʄ> Facet<'ʄ> for HttpOutcome

Source§

const SHAPE: &'static Shape

The shape of this type, including: whether it’s a Struct, an Enum, something else? Read more
Source§

impl PartialEq for HttpOutcome

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for HttpOutcome

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for HttpOutcome

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.