ApiShowMyAddressResponse

Enum ApiShowMyAddressResponse 

Source
#[non_exhaustive]
pub enum ApiShowMyAddressResponse { UserContactLink(UserContactLinkResponse), ChatCmdError(ChatCmdErrorResponse), Undocumented(Value), }

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

UserContactLink: User contact address.

§

ChatCmdError(ChatCmdErrorResponse)

ChatCmdError: Command error.

§

Undocumented(Value)

Implementations§

Source§

impl ApiShowMyAddressResponse

Examples found in repository?
examples/multi_user_bot.rs (line 42)
23async fn main() -> Result<(), Box<dyn Error>> {
24    let (client, mut events) = simploxide_client::connect("ws://127.0.0.1:5225").await?;
25
26    // Use destructuring to extract data from the expected response
27    let ShowActiveUserResponse::ActiveUser(ActiveUserResponse { ref user, .. }) =
28        *client.show_active_user().await?
29    else {
30        return Err("No active user profile".into());
31    };
32
33    println!(
34        "Bot profile: {} ({})",
35        user.profile.display_name, user.profile.full_name
36    );
37
38    // Alternatively, use response getters
39    let (address_long, address_short) = match client
40        .api_show_my_address(user.user_id)
41        .await?
42        .user_contact_link()
43    {
44        Some(resp) => (
45            resp.contact_link.conn_link_contact.conn_full_link.clone(),
46            resp.contact_link.conn_link_contact.conn_short_link.clone(),
47        ),
48        None => client
49            .api_create_my_address(user.user_id)
50            .await?
51            .user_contact_link_created()
52            .map(|resp| {
53                (
54                    resp.conn_link_contact.conn_full_link.clone(),
55                    resp.conn_link_contact.conn_short_link.clone(),
56                )
57            })
58            .ok_or("Failed to create bot address")?,
59    };
60
61    println!("Bot long address: {address_long}");
62    println!("Bot short address: {address_short:?}");
63
64    let mut counter = 0;
65    'reactor: while let Some(ev) = events.try_next().await? {
66        match ev.as_ref() {
67            // Got the message -> square the number
68            Event::NewChatItems(new_msgs) => {
69                counter += 1;
70                if counter > 10 {
71                    break 'reactor;
72                }
73            }
74            // Ignore all other events
75            _ => (),
76        }
77    }
78
79    client
80        .api_set_address_settings(
81            user.user_id,
82            AddressSettings {
83                business_address: false,
84                auto_accept: None,
85                auto_reply: None,
86                undocumented: Default::default(),
87            },
88        )
89        .await?;
90
91    client
92        .api_set_profile_address(ApiSetProfileAddress {
93            user_id: user.user_id,
94            enable: false,
95        })
96        .await?;
97
98    Ok(())
99}
Source

pub fn chat_cmd_error(&self) -> Option<&ChatCmdErrorResponse>

Source

pub fn undocumented(&self) -> Option<&Value>

Trait Implementations§

Source§

impl Clone for ApiShowMyAddressResponse

Source§

fn clone(&self) -> ApiShowMyAddressResponse

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 ApiShowMyAddressResponse

Source§

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

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

impl<'de> Deserialize<'de> for ApiShowMyAddressResponse

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ApiShowMyAddressResponse, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ApiShowMyAddressResponse

Source§

fn eq(&self, other: &ApiShowMyAddressResponse) -> 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 Serialize for ApiShowMyAddressResponse

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ApiShowMyAddressResponse

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,