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])
👎Deprecated since 0.16.1: Use try_split_from instead.
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).
§Panics
Panics if inp
is empty.
sourcepub fn try_split_from(inp: &[u8]) -> Option<(Self, &[u8])>
pub fn try_split_from(inp: &[u8]) -> Option<(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).
Returns None if the input was empty.
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>
source§fn encode_onto<W: Writer + ?Sized>(self, w: &mut W) -> EncodeResult<()>
fn encode_onto<W: Writer + ?Sized>(self, w: &mut W) -> EncodeResult<()>
source§impl From<Data> for AnyRelayMsg
impl From<Data> for AnyRelayMsg
source§fn from(m: Data) -> AnyRelayMsg
fn from(m: Data) -> AnyRelayMsg
Auto Trait Implementations§
impl Freeze for Data
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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>,
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>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)