[][src]Struct torut::control::Conn

pub struct Conn<S> { /* fields omitted */ }

Conn wraps any AsyncRead + AsyncWrite stream and implements parsing responses from tor and sending data to it.

It's stateless component. It does not contain any information about connection like authentication state.

Note

This is fairly low-level connection which does only basic parsing. Unless you need it you should use higher level apis.

Implementations

impl<S> Conn<S>[src]

pub fn new(stream: S) -> Self[src]

pub fn into_inner(self) -> S[src]

impl<S> Conn<S> where
    S: AsyncRead + Unpin
[src]

pub async fn receive_data<'_>(
    &'_ mut self
) -> Result<(u16, Vec<String>), ConnError>
[src]

receive_data receives single response from tor

Response format

Rather than grouping response by lines sent on proto it groups it on "lines" returned by tor. Take a look at tests to see what's going on. Basically all multiline mode data is put into one string despite the fact that it may contain multiple lines.

Performance considerations

This function allocates all stuff and does not allow writing to any preallocated buffer. It neither does not allow for any kind of borrowing from one big buffer.

Personally I think it's not needed. It's tor api how many data you want receive from it? Anyway this won't be ran on any embedded device(because it has to be able to run tor, it has to run at least some linux so I probably can allocate a few strings on it...)

Possible performance issues

It uses byte-by-byte reading. Thanks to this feature there is no state in Conn struct. Use some sort of buffered reader in order to minimize overhead.

impl<S> Conn<S> where
    S: AsyncWrite + Unpin
[src]

pub async fn write_data<'_, '_>(
    &'_ mut self,
    data: &'_ [u8]
) -> Result<(), ConnError>
[src]

write_data writes RAW data into tor controller and flushes stream

Trait Implementations

impl<S> From<Conn<S>> for UnauthenticatedConn<S>[src]

impl<S, H> From<Conn<S>> for AuthenticatedConn<S, H>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for Conn<S> where
    S: RefUnwindSafe

impl<S> Send for Conn<S> where
    S: Send

impl<S> Sync for Conn<S> where
    S: Sync

impl<S> Unpin for Conn<S> where
    S: Unpin

impl<S> UnwindSafe for Conn<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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