pub struct UntypedRequest<'a> {
pub header: Cow<'a, [u8]>,
pub id: Cow<'a, str>,
pub payload: Cow<'a, [u8]>,
}
Expand description
Represents a request to send whose payload is bytes instead of a specific type
Fields§
§header: Cow<'a, [u8]>
Header data associated with the request as bytes
id: Cow<'a, str>
Unique id associated with the request
payload: Cow<'a, [u8]>
Payload associated with the request as bytes
Implementations§
Source§impl<'a> UntypedRequest<'a>
impl<'a> UntypedRequest<'a>
Sourcepub fn to_typed_request<T: DeserializeOwned>(&self) -> Result<Request<T>>
pub fn to_typed_request<T: DeserializeOwned>(&self) -> Result<Request<T>>
Attempts to convert an untyped request to a typed request
Sourcepub fn as_borrowed(&self) -> UntypedRequest<'_>
pub fn as_borrowed(&self) -> UntypedRequest<'_>
Convert into a borrowed version
Sourcepub fn into_owned(self) -> UntypedRequest<'static>
pub fn into_owned(self) -> UntypedRequest<'static>
Convert into an owned version
Sourcepub fn set_header(&mut self, header: impl IntoIterator<Item = u8>)
pub fn set_header(&mut self, header: impl IntoIterator<Item = u8>)
Updates the header of the request to the given header
.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Allocates a new collection of bytes representing the request.
Sourcepub fn from_slice(input: &'a [u8]) -> Result<Self, UntypedRequestParseError>
pub fn from_slice(input: &'a [u8]) -> Result<Self, UntypedRequestParseError>
Parses a collection of bytes, returning a partial request if it can be potentially
represented as a Request
depending on the payload.
NOTE: This supports parsing an invalid request where the payload would not properly deserialize, but the bytes themselves represent a complete request of some kind.
Trait Implementations§
Source§impl<'a> Clone for UntypedRequest<'a>
impl<'a> Clone for UntypedRequest<'a>
Source§fn clone(&self) -> UntypedRequest<'a>
fn clone(&self) -> UntypedRequest<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for UntypedRequest<'a>
impl<'a> Debug for UntypedRequest<'a>
Source§impl<'de, 'a> Deserialize<'de> for UntypedRequest<'a>
impl<'de, 'a> Deserialize<'de> for UntypedRequest<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<'a> PartialEq for UntypedRequest<'a>
impl<'a> PartialEq for UntypedRequest<'a>
Source§impl<'a> Serialize for UntypedRequest<'a>
impl<'a> Serialize for UntypedRequest<'a>
impl<'a> Eq for UntypedRequest<'a>
impl<'a> StructuralPartialEq for UntypedRequest<'a>
Auto Trait Implementations§
impl<'a> Freeze for UntypedRequest<'a>
impl<'a> RefUnwindSafe for UntypedRequest<'a>
impl<'a> Send for UntypedRequest<'a>
impl<'a> Sync for UntypedRequest<'a>
impl<'a> Unpin for UntypedRequest<'a>
impl<'a> UnwindSafe for UntypedRequest<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more