CloseReason

Enum CloseReason 

Source
pub enum CloseReason {
Show 14 variants None = 0, Protocol = 1, Internal = 2, Requested = 3, Hibernating = 4, ResourceLimit = 5, ConnectFailed = 6, OrIdentity = 7, ChannelClosed = 8, Finished = 9, Timeout = 10, Destroyed = 11, NoSuchService = 12, Unknown = 13,
}
Expand description

Reason for closing a circuit or stream.

These codes indicate why a relay closed a circuit or stream. They are used in DESTROY cells and RELAY_END cells.

§Variants

ReasonValueDescription
None0No reason given
Protocol1Tor protocol violation
Internal2Internal error
Requested3Client sent TRUNCATE command
Hibernating4Relay suspended to save bandwidth
ResourceLimit5Out of memory, sockets, or circuit IDs
ConnectFailed6Unable to reach relay
OrIdentity7Connected but OR identity was wrong
ChannelClosed8Connection carrying this circuit died
Finished9Circuit expired (dirty or old)
Timeout10Circuit construction took too long
Destroyed11Circuit destroyed without client TRUNCATE
NoSuchService12Request for unknown hidden service
Unknown-Unrecognized reason

§Example

use stem_rs::client::datatype::CloseReason;

let (reason, raw) = CloseReason::get(3);
assert_eq!(reason, CloseReason::Requested);
assert_eq!(format!("{}", reason), "REQUESTED");

Variants§

§

None = 0

No reason given.

§

Protocol = 1

Tor protocol violation.

§

Internal = 2

Internal error.

§

Requested = 3

Client sent a TRUNCATE command.

§

Hibernating = 4

Relay suspended, trying to save bandwidth.

§

ResourceLimit = 5

Out of memory, sockets, or circuit IDs.

§

ConnectFailed = 6

Unable to reach relay.

§

OrIdentity = 7

Connected, but its OR identity was not as expected.

§

ChannelClosed = 8

Connection that was carrying this circuit died.

§

Finished = 9

Circuit has expired for being dirty or old.

§

Timeout = 10

Circuit construction took too long.

§

Destroyed = 11

Circuit was destroyed without a client TRUNCATE.

§

NoSuchService = 12

Request was for an unknown hidden service.

§

Unknown = 13

Unrecognized reason.

Implementations§

Source§

impl CloseReason

Source

pub fn get(val: u8) -> (CloseReason, u8)

Converts a raw byte value to a CloseReason and its integer representation.

§Arguments
  • val - The raw reason byte from the protocol
§Returns

A tuple of (CloseReason, u8) where the second element is the original byte value.

Source

pub fn value(&self) -> u8

Returns the integer value for this close reason.

Returns 255 for Unknown reasons.

Trait Implementations§

Source§

impl Clone for CloseReason

Source§

fn clone(&self) -> CloseReason

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 CloseReason

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for CloseReason

Source§

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

Formats the close reason as its canonical string name.

Source§

impl Hash for CloseReason

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CloseReason

Source§

fn eq(&self, other: &CloseReason) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CloseReason

Source§

impl Eq for CloseReason

Source§

impl StructuralPartialEq for CloseReason

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.