Struct cocaine::Request [−][src]
pub struct Request { /* fields omitted */ }
A generic Cocaine request.
Encapsulates all required parameters to be able to perform a service call.
Examples
use cocaine::Request; use cocaine::hpack::{Header, TraceId, SpanId}; let request = Request::new(0, &["event"]).unwrap() .add_headers(vec![TraceId(0).into_raw(), SpanId(42).into_raw()]); assert_eq!(0, request.ty());
Errors
A serialization error is returned when it's failed to serialize the given arguments into a vector. However, while a vector is grown automatically, it may only fail when there is no memory left for allocation.
Methods
impl Request
[src]
impl Request
pub fn new<S: Serialize>(ty: u64, args: &S) -> Result<Self, Error>
[src]
pub fn new<S: Serialize>(ty: u64, args: &S) -> Result<Self, Error>
Constructs a new request object using the given message type and arguments, performing an automatic serialization.
pub fn ty(&self) -> u64
[src]
pub fn ty(&self) -> u64
Returns a request type.
pub fn data(&self) -> &[u8]
[src]
pub fn data(&self) -> &[u8]
Returns a serialized request arguments as a slice.
pub fn headers(&self) -> &[RawHeader]
[src]
pub fn headers(&self) -> &[RawHeader]
Returns a reference to the request headers.
pub fn add_header<H: Into<RawHeader>>(self, header: H) -> Self
[src]
pub fn add_header<H: Into<RawHeader>>(self, header: H) -> Self
Adds a header to the request.
pub fn add_headers<H: IntoIterator<Item = RawHeader>>(self, headers: H) -> Self
[src]
pub fn add_headers<H: IntoIterator<Item = RawHeader>>(self, headers: H) -> Self
Adds an iterable headers object to the request.
Trait Implementations
impl Clone for Request
[src]
impl Clone for Request
fn clone(&self) -> Request
[src]
fn clone(&self) -> Request
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl Debug for Request
[src]
impl Debug for Request