[−][src]Struct torut::control::Conn
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]
S: AsyncRead + Unpin,
pub async fn receive_data<'_>(
&'_ mut self
) -> Result<(u16, Vec<String>), ConnError>
[src]
&'_ mut self
) -> Result<(u16, Vec<String>), ConnError>
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]
S: AsyncWrite + Unpin,
pub async fn write_data<'_, '_>(
&'_ mut self,
data: &'_ [u8]
) -> Result<(), ConnError>
[src]
&'_ mut self,
data: &'_ [u8]
) -> Result<(), ConnError>
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,
S: RefUnwindSafe,
impl<S> Send for Conn<S> where
S: Send,
S: Send,
impl<S> Sync for Conn<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Conn<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Conn<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,