MapAddressResponse

Struct MapAddressResponse 

Source
pub struct MapAddressResponse {
    pub mapped: HashMap<String, String>,
    pub failures: Vec<String>,
}
Expand description

Parsed response from the MAPADDRESS command.

Contains successful address mappings and any failure messages. Responses can contain a mixture of successes and failures.

§Example

use stem_rs::response::{ControlMessage, MapAddressResponse};

// Response with multiple mappings
let msg = ControlMessage::from_str(
    "250-foo=bar\r\n\
     250-baz=quux\r\n\
     250 192.0.2.1=example.com\r\n",
    None,
    false
).unwrap();

let response = MapAddressResponse::from_message(&msg).unwrap();
assert_eq!(response.mapped.len(), 3);
assert_eq!(response.mapped.get("foo"), Some(&"bar".to_string()));

Fields§

§mapped: HashMap<String, String>

Successful address mappings.

Maps the original address (key) to the replacement address (value). For example, "1.2.3.4" => "tor.freehaven.net" means connections to 1.2.3.4 will be redirected to tor.freehaven.net.

§failures: Vec<String>

Failure messages for mappings that could not be created.

Each string contains the error message from Tor explaining why the mapping failed (e.g., “syntax error: invalid address ‘@@@’”).

Implementations§

Source§

impl MapAddressResponse

Source

pub fn from_message(message: &ControlMessage) -> Result<Self, Error>

Parses a MAPADDRESS response from a control message.

Extracts successful mappings and failure messages from the response. This method only returns an error if ALL mappings fail or if the response format is invalid.

§Arguments
  • message - The control message to parse
§Errors

Returns an error if:

§Example
use stem_rs::response::{ControlMessage, MapAddressResponse};

// Successful mapping
let msg = ControlMessage::from_str(
    "250 192.0.2.1=example.com\r\n",
    None,
    false
).unwrap();
let response = MapAddressResponse::from_message(&msg).unwrap();
assert_eq!(
    response.mapped.get("192.0.2.1"),
    Some(&"example.com".to_string())
);

Trait Implementations§

Source§

impl Clone for MapAddressResponse

Source§

fn clone(&self) -> MapAddressResponse

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 MapAddressResponse

Source§

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

Formats the value using the given formatter. Read more

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