[−][src]Struct solicit::http::frame::RawFrame
A struct that defines the format of the raw HTTP/2 frame, i.e. the frame as it is read from the wire.
This format is defined in section 4.1. of the HTTP/2 spec.
The RawFrame
struct simply stores the raw components of an HTTP/2 frame:
its header and the payload as a sequence of bytes.
It does not try to interpret the payload bytes, nor do any validation in terms of its validity based on the frame type given in the header. It is simply a wrapper around the two parts of an HTTP/2 frame.
Implementations
impl<'a> RawFrame<'a>
[src]
pub fn parse(buf: &'a [u8]) -> Option<RawFrame<'a>>
[src]
Parses a RawFrame
from the bytes starting at the beginning of the given buffer.
Returns the None
variant when it is not possible to parse a raw frame from the buffer
(due to there not being enough bytes in the buffer). If the RawFrame
is successfully
parsed it returns the frame, borrowing a part of the original buffer. Therefore, this
method makes no copies, nor does it perform any extra allocations.
Examples
use solicit::http::frame::RawFrame; let buf = b"123"; // Not enough bytes for even the header of the frame assert!(RawFrame::parse(&buf[..]).is_none());
use solicit::http::frame::RawFrame; let buf = vec![0, 0, 1, 0, 0, 0, 0, 0, 0]; // Full header, but not enough bytes for the payload assert!(RawFrame::parse(&buf[..]).is_none());
use solicit::http::frame::RawFrame; let buf = vec![0, 0, 1, 0, 0, 0, 0, 0, 0, 1]; // A full frame is extracted, even if in this case the frame itself is not valid (a DATA // frame associated to stream 0 is not valid in HTTP/2!). This, however, is not the // responsibility of the RawFrame. let frame = RawFrame::parse(&buf[..]).unwrap(); assert_eq!(frame.as_ref(), &buf[..]);
pub fn len(&self) -> usize
[src]
Returns the total length of the RawFrame
, including both headers, as well as the entire
payload.
pub fn serialize(&self) -> Vec<u8>
[src]
Returns a Vec
of bytes representing the serialized (on-the-wire)
representation of this raw frame.
pub fn header(&self) -> FrameHeader
[src]
Returns a FrameHeader
instance corresponding to the headers of the
RawFrame
.
pub fn payload(&self) -> &[u8]
[src]
Returns a slice representing the payload of the RawFrame
.
Trait Implementations
impl<'a> AsRef<[u8]> for RawFrame<'a>
[src]
impl<'a> Clone for RawFrame<'a>
[src]
impl<'a> Debug for RawFrame<'a>
[src]
impl<'a> FrameIR for RawFrame<'a>
[src]
RawFrame
s can be serialized to an on-the-wire format.
fn serialize_into<B: FrameBuilder>(self, b: &mut B) -> Result<()>
[src]
impl<'a> From<&'a [u8]> for RawFrame<'a>
[src]
impl<'a> From<Vec<u8>> for RawFrame<'a>
[src]
Provide a conversion from a Vec
.
This conversion is unchecked and could cause the resulting RawFrame
to be an
invalid HTTP/2 frame.
impl<'a> Into<Vec<u8>> for RawFrame<'a>
[src]
impl<'a> PartialEq<RawFrame<'a>> for RawFrame<'a>
[src]
impl<'a> StructuralPartialEq for RawFrame<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for RawFrame<'a>
impl<'a> Send for RawFrame<'a>
impl<'a> Sync for RawFrame<'a>
impl<'a> Unpin for RawFrame<'a>
impl<'a> UnwindSafe for RawFrame<'a>
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,