[][src]Struct k8s_openapi::ResponseBody

pub struct ResponseBody<T> {
    pub status_code: StatusCode,
    // some fields omitted
}

This struct provides an easy way to parse a byte buffer into a Kubernetes API function's response.

All API function responses implement the Response trait, and are constructed by calling their Response::try_from_parts function. If this function returns Err(ResponseError::NeedMoreData), that means more bytes need to be appended to the function. Alternatively, if the function returns Ok((value, num_bytes_read)), then num_bytes_read bytes need to be popped off from the front of the buffer.

The ResponseBody struct contains an internal dynamic buffer, and provides append_slice and parse functions to help with this. append_slice appends the slice you give it to its internal buffer, and parse uses the Response::try_from_parts function to parse the response out of the buffer, and truncates it accordingly.

You do not have to use this type to parse the response, say if you want to manage your own byte buffers. You can use <T as Response>::try_from_parts directly instead.

Fields

status_code: StatusCode

The HTTP status code of the response.

Methods

impl<T> ResponseBody<T> where
    T: Response
[src]

pub fn new(status_code: StatusCode) -> Self[src]

Construct a value for a response that has the specified HTTP status code.

pub fn append_slice(&mut self, buf: &[u8])[src]

Append a slice of data from the HTTP response to this buffer.

pub fn parse(&mut self) -> Result<T, ResponseError>[src]

Try to parse all the data buffered so far into a response type.

pub fn advance(&mut self, cnt: usize)[src]

Drop the first cnt bytes of this buffer.

This is useful for skipping over malformed bytes, such as invalid utf-8 sequences when parsing streaming String responses like from api::core::v1::Pod::read_namespaced_pod_log.

Panics

This function panics if cnt > self.len()

Trait Implementations

impl<T> Deref for ResponseBody<T>[src]

type Target = [u8]

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> Send for ResponseBody<T>

impl<T> Sync for ResponseBody<T>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]