Skip to main content

StreamPeer

Struct StreamPeer 

Source
pub struct StreamPeer<R, W> { /* private fields */ }
Expand description

A peer at the other end of a connection, where serve answers.

input is what the other end sends, and output is what it reads. An answer that is left half read, because a frame of it was refused, leaves the connection where nobody knows what comes next. Nothing more is asked on it then: open a new one.

Implementations§

Source§

impl<R: Read, W: Write> StreamPeer<R, W>

Source

pub fn new(input: R, output: W) -> Self

Trait Implementations§

Source§

impl<R: Read, W: Write> Peer for StreamPeer<R, W>

Source§

fn ask( &mut self, request: &[u8], limit: usize, on_frame: &mut dyn FnMut(&[u8]) -> Result<()>, ) -> Result<()>

Sends one request, and hands each frame of the answer to on_frame in the order the frames come. An error from on_frame ends the answer, and is what ask returns. Read more
Source§

fn ask_all( &mut self, requests: &[(Vec<u8>, usize)], on_frame: &mut dyn FnMut(usize, &[u8]) -> Result<()>, ) -> Result<()>

Sends several requests, each with its limit, and hands each frame to on_frame with the place of the request that it answers. Answers come in the order of the requests. Read more

Auto Trait Implementations§

§

impl<R, W> Forget for StreamPeer<R, W>

§

impl<R, W> Freeze for StreamPeer<R, W>
where R: Freeze, W: Freeze,

§

impl<R, W> Move for StreamPeer<R, W>

§

impl<R, W> RefUnwindSafe for StreamPeer<R, W>

§

impl<R, W> Send for StreamPeer<R, W>
where R: Send, W: Send,

§

impl<R, W> Sync for StreamPeer<R, W>
where R: Sync, W: Sync,

§

impl<R, W> Unpin for StreamPeer<R, W>
where R: Unpin, W: Unpin,

§

impl<R, W> UnsafeUnpin for StreamPeer<R, W>
where R: UnsafeUnpin, W: UnsafeUnpin,

§

impl<R, W> UnwindSafe for StreamPeer<R, W>
where R: UnwindSafe, W: UnwindSafe,

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
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.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.