[−][src]Struct k8s_openapi::ResponseBody
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: StatusCodeThe HTTP status code of the response.
Methods
impl<T> ResponseBody<T> where
T: Response, [src]
T: Response,
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 is greater than the length of the internal buffer.
Trait Implementations
impl<T> Deref for ResponseBody<T>[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for ResponseBody<T>
impl<T> Send for ResponseBody<T>
impl<T> Sync for ResponseBody<T>
impl<T> Unpin for ResponseBody<T>
impl<T> UnwindSafe for ResponseBody<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,