Struct RecvStep

Source
pub struct RecvStep<'b, P: ReadPrecision> {
    buffer: &'b mut Buffer<P>,
    deficit: NonZeroUsize,
}
Available on crate features proxy-handshake or client-handshake only.
Expand description

Next step - details for reading from the peer

Value in NextStep::Recv.

Caller should read from the peer and call one of the received functions. Specifically, caller should do one of the following:

  1. Read some data into the slice returned by .buf(), and then call .note_received().

  2. Determine the available buffer space with .buf().len(), write some data into the buffer’s unfilled_slice(), and call Buffer::note_received. This allows the caller to dispose of the RecvStep (which mutably borrows the Buffer) while reading, at the cost of slightly less correctness checking by the compiler.

The caller should not wait for enough data to fill the whole buf.

Fields§

§buffer: &'b mut Buffer<P>

The buffer

§deficit: NonZeroUsize

Lower bound on the number of bytes that the handshake needs to read to complete.

Useful only for callers that want to avoid reading beyond the end of the handshake. Always <= .buf().len().

The returned value has the same semantics as [tor_bytes::IncompleteMessage.deficit.

Implementations§

Source§

impl<'b, P: ReadPrecision> RecvStep<'b, P>

Source

pub fn buf(&mut self) -> &mut [u8]

Returns the buffer slice the caller should write data into.

For precise reads, returns the slice of the buffer of length deficit. sol as to avoid reading ahead beyond the end of the handshake.

Source

pub fn note_received(self, len: usize) -> Result<(), Error>

Notes that len bytes have been received.

The actual data must already have been written to the slice from .buf().

If len == 0, treats this as having received EOF (which is an error).

§Panics

len must be no more than .buf().len().

Trait Implementations§

Source§

impl<'b, P: Debug + ReadPrecision> Debug for RecvStep<'b, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, P> Freeze for RecvStep<'b, P>

§

impl<'b, P> RefUnwindSafe for RecvStep<'b, P>
where P: RefUnwindSafe,

§

impl<'b, P> Send for RecvStep<'b, P>
where P: Send,

§

impl<'b, P> Sync for RecvStep<'b, P>
where P: Sync,

§

impl<'b, P> Unpin for RecvStep<'b, P>

§

impl<'b, P> !UnwindSafe for RecvStep<'b, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T