Stream

Struct Stream 

Source
pub struct Stream {
    pub id: StreamId,
    pub status: StreamStatus,
    pub circuit_id: Option<CircuitId>,
    pub target_host: String,
    pub target_port: u16,
}
Expand description

Information about an active Tor stream.

A stream represents a single TCP connection being routed through a Tor circuit. Streams are created when applications connect through Tor’s SOCKS proxy and are attached to circuits for routing.

§Stream Lifecycle

Streams progress through several states:

  1. New: Stream created, awaiting circuit attachment
  2. SentConnect: CONNECT command sent to exit relay
  3. Succeeded: Connection established successfully
  4. Failed: Connection attempt failed
  5. Closed: Stream has been closed

§Fields

  • id: Unique identifier for this stream
  • status: Current state of the stream
  • circuit_id: The circuit this stream is attached to (if any)
  • target_host: Destination hostname or IP address
  • target_port: Destination port number

§Example

use stem_rs::controller::Controller;
use stem_rs::StreamStatus;

let mut controller = Controller::from_port("127.0.0.1:9051".parse()?).await?;
controller.authenticate(None).await?;

for stream in controller.get_streams().await? {
    println!("Stream {} -> {}:{} ({:?})",
        stream.id,
        stream.target_host,
        stream.target_port,
        stream.status
    );
    if let Some(ref circuit_id) = stream.circuit_id {
        println!("  Attached to circuit {}", circuit_id);
    }
}

§See Also

Fields§

§id: StreamId

Unique identifier for this stream.

§status: StreamStatus

Current status of the stream.

See StreamStatus for possible values.

§circuit_id: Option<CircuitId>

The circuit this stream is attached to, if any.

Streams in the New or Detached state may not be attached to any circuit. Once attached, this field contains the circuit ID.

§target_host: String

Destination hostname or IP address.

This is the target the stream is connecting to through Tor.

§target_port: u16

Destination port number.

The TCP port on the target host. May be 0 if not specified.

Trait Implementations§

Source§

impl Clone for Stream

Source§

fn clone(&self) -> Stream

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stream

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Stream

§

impl RefUnwindSafe for Stream

§

impl Send for Stream

§

impl Sync for Stream

§

impl Unpin for Stream

§

impl UnwindSafe for Stream

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.