pub struct Data { /* private fields */ }Expand description
A Data message represents data sent along a stream.
Upon receiving a Data message for a live stream, the client or exit sends that data onto the associated TCP connection.
These messages hold between 1 and Data::MAXLEN bytes of data each; they are the most numerous messages on the Tor network.
Implementations§
source§impl Data
impl Data
sourcepub const MAXLEN: usize = 498usize
pub const MAXLEN: usize = 498usize
The longest allowable body length for a single data cell. Relay command (1) + ‘Recognized’ (2) + StreamID (2) + Digest (4) + Length (2) = 11
sourcepub fn new(inp: &[u8]) -> Result<Self>
pub fn new(inp: &[u8]) -> Result<Self>
Construct a new data cell.
Returns an error if inp is longer than Data::MAXLEN bytes.
sourcepub fn split_from(inp: &[u8]) -> (Self, &[u8])
pub fn split_from(inp: &[u8]) -> (Self, &[u8])
Construct a new data cell, taking as many bytes from inp
as possible.
Return the data cell, and a slice holding any bytes that wouldn’t fit (if any).
Trait Implementations§
source§impl Body for Data
impl Body for Data
source§fn decode_from_reader(r: &mut Reader<'_>) -> Result<Self>
fn decode_from_reader(r: &mut Reader<'_>) -> Result<Self>
Decode a relay cell body from a provided reader.
source§fn encode_onto<W: Writer + ?Sized>(self, w: &mut W) -> EncodeResult<()>
fn encode_onto<W: Writer + ?Sized>(self, w: &mut W) -> EncodeResult<()>
Encode the body of this cell into the end of a writer.
source§impl From<Data> for AnyRelayMsg
impl From<Data> for AnyRelayMsg
source§fn from(m: Data) -> AnyRelayMsg
fn from(m: Data) -> AnyRelayMsg
Converts to this type from the input type.
Auto Trait Implementations§
impl RefUnwindSafe for Data
impl Send for Data
impl Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)