ApiCreateMyAddressResponse

Enum ApiCreateMyAddressResponse 

Source
#[non_exhaustive]
pub enum ApiCreateMyAddressResponse { UserContactLinkCreated(UserContactLinkCreatedResponse), ChatCmdError(ChatCmdErrorResponse), Undocumented(BTreeMap<String, 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.
§

UserContactLinkCreated(UserContactLinkCreatedResponse)

UserContactLinkCreated: User contact address created.

§

ChatCmdError(ChatCmdErrorResponse)

ChatCmdError: Command error.

§

Undocumented(BTreeMap<String, Value>)

Implementations§

Source§

impl ApiCreateMyAddressResponse

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

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

Source

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

Trait Implementations§

Source§

impl Clone for ApiCreateMyAddressResponse

Source§

fn clone(&self) -> ApiCreateMyAddressResponse

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 ApiCreateMyAddressResponse

Source§

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

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

impl<'de> Deserialize<'de> for ApiCreateMyAddressResponse

Source§

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

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

impl PartialEq for ApiCreateMyAddressResponse

Source§

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

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 ApiCreateMyAddressResponse

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