Struct cocaine::Response [] [src]

pub struct Response<'a: 'b, 'b> { /* fields omitted */ }

Generic response type.

Methods

impl<'a: 'b, 'b> Response<'a, 'b>
[src]

[src]

Returns a response type.

[src]

Deserializes the response into the specified type.

Note, that this method can also be used to deserialize a response into some borrowed type, like &str, &[u8] or into an user-defined type that contains them. In this case the deserialization is completely zero-copy.

Errors

This method can fail if the underlying deserializer decides to fail.

Examples

This example demonstrates how to use deserialization into a borrowed struct.

use cocaine::{Error, Response};

#[derive(Debug, Deserialize)]
struct User<'a> {
    name: &'a str,
    age: u16,
}

fn handle(resp: &Response) -> Result<(), Error> {
    let user: User = resp.deserialize()?;
    println!("User: {:?}", user);
    Ok(())
}

[src]

Returns response headers.

Trait Implementations

impl<'a: 'b, 'b> Debug for Response<'a, 'b>
[src]

[src]

Formats the value using the given formatter.