Chat

Struct Chat 

Source
pub struct Chat {
Show 14 fields pub id: String, pub local_chat_id: Option<String>, pub account_id: String, pub network: String, pub title: String, pub chat_type: String, pub participants: Participants, pub last_activity: Option<String>, pub unread_count: u32, pub last_read_message_sort_key: Option<u64>, pub is_archived: bool, pub is_muted: bool, pub is_pinned: bool, pub preview: Option<Box<Message>>,
}
Expand description

A chat or conversation

Fields§

§id: String

Unique chat ID

§local_chat_id: Option<String>

Local chat ID specific to this Beeper Desktop installation

§account_id: String

Account ID this chat belongs to, generaly “whatsapp” etc.

§network: String

Display-only human-readable network name (e.g., ‘WhatsApp’, ‘Messenger’)

§title: String

Display title of the chat

§chat_type: String

Chat type: ‘single’ for direct messages, ‘group’ for group chats

§participants: Participants

Chat participants information

§last_activity: Option<String>

Timestamp of last activity

§unread_count: u32

Number of unread messages

§last_read_message_sort_key: Option<u64>

Last read message sortKey

§is_archived: bool

True if chat is archived

§is_muted: bool

True if chat notifications are muted

§is_pinned: bool

True if chat is pinned

§preview: Option<Box<Message>>

Last message preview for this chat, if available

Implementations§

Source§

impl Chat

Source

pub fn display_name(&self) -> String

Get a display name for the chat

For direct messages (‘single’), returns the participant’s full name or username. For group chats, returns the chat title.

Examples found in repository?
examples/fetch_chats.rs (line 32)
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    // Get authentication token from environment variable
7    let token = env::var("BEEPER_TOKEN")
8        .unwrap_or_else(|_| {
9            eprintln!("Error: BEEPER_TOKEN environment variable not set");
10            eprintln!("Usage: BEEPER_TOKEN=your_token cargo run --example fetch_chats");
11            std::process::exit(1);
12        });
13
14    // Get API base URL from environment variable or use default
15    let base_url = env::var("BEEPER_API_URL")
16        .unwrap_or_else(|_| "http://localhost:23373".to_string());
17
18    println!("Connecting to Beeper Desktop API at: {}", base_url);
19    println!();
20
21    // Create a client with the provided token
22    let client = BeeperClient::new(&token, &base_url);
23
24    // Fetch all chats
25    println!("📋 Fetching chats from Beeper...");
26    let chats_response = client.list_chats(None, None).await?;
27
28    // Extract chat names into a vector using the display_name method
29    let chat_names: Vec<String> = chats_response
30        .items
31        .iter()
32        .map(|chat| chat.display_name())
33        .collect();
34
35    // Display results
36    println!("✅ Successfully retrieved {} chats:", chat_names.len());
37    println!();
38
39    if chat_names.is_empty() {
40        println!("No chats found.");
41    } else {
42        for (index, name) in chat_names.iter().enumerate() {
43            println!("  {}. {}", index + 1, name);
44        }
45    }
46
47    println!();
48    println!("Chat names as array:");
49    println!("{:#?}", chat_names);
50
51    Ok(())
52}

Trait Implementations§

Source§

impl Clone for Chat

Source§

fn clone(&self) -> Chat

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 Chat

Source§

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

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

impl<'de> Deserialize<'de> for Chat

Source§

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

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

impl Serialize for Chat

Source§

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Chat

§

impl RefUnwindSafe for Chat

§

impl Send for Chat

§

impl Sync for Chat

§

impl Unpin for Chat

§

impl UnwindSafe for Chat

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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