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: StringUnique chat ID
local_chat_id: Option<String>Local chat ID specific to this Beeper Desktop installation
account_id: StringAccount ID this chat belongs to, generaly “whatsapp” etc.
network: StringDisplay-only human-readable network name (e.g., ‘WhatsApp’, ‘Messenger’)
title: StringDisplay title of the chat
chat_type: StringChat type: ‘single’ for direct messages, ‘group’ for group chats
participants: ParticipantsChat participants information
last_activity: Option<String>Timestamp of last activity
unread_count: u32Number of unread messages
last_read_message_sort_key: Option<u64>Last read message sortKey
is_archived: boolTrue if chat is archived
is_muted: boolTrue if chat notifications are muted
is_pinned: boolTrue if chat is pinned
preview: Option<Box<Message>>Last message preview for this chat, if available
Implementations§
Source§impl Chat
impl Chat
Sourcepub fn display_name(&self) -> String
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<'de> Deserialize<'de> for Chat
impl<'de> Deserialize<'de> for Chat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more