zoe_client/client/
api.rs

1use super::{
2    ZoeClientBlobService, ZoeClientMessageManager, ZoeClientSessionManager, ZoeClientStorage,
3};
4use crate::error::Result;
5use std::sync::Arc;
6use zoe_blob_store::BlobClient;
7use zoe_state_machine::GroupManager;
8use zoe_wire_protocol::{KeyPair, VerifyingKey};
9
10#[cfg(not(feature = "frb-api"))]
11mod file_storage;
12#[cfg(not(feature = "frb-api"))]
13mod relay;
14#[cfg(not(feature = "frb-api"))]
15mod secret;
16
17// need to be public for flutter rust bridge
18#[cfg(feature = "frb-api")]
19pub mod file_storage;
20#[cfg(feature = "frb-api")]
21pub mod relay;
22#[cfg(feature = "frb-api")]
23pub mod secret;
24
25pub use super::Client;
26
27#[cfg(feature = "frb-api")]
28use flutter_rust_bridge::frb;
29
30#[cfg_attr(feature = "frb-api", frb)]
31// File Storage
32impl Client {
33    pub fn client_secret_hex(&self) -> Result<String> {
34        self.client_secret.to_hex()
35    }
36
37    pub fn id_hex(&self) -> String {
38        hex::encode(self.client_secret.inner_keypair.id())
39    }
40
41    /// Close the client and clean up all resources
42    /// Get access to the session manager for PQXDH operations
43    ///
44    /// This provides access to the underlying session manager which handles
45    /// PQXDH protocol handlers and state management.
46    ///
47    /// # Returns
48    ///
49    /// A reference to the `SessionManager`
50    pub fn session_manager(&self) -> Arc<ZoeClientSessionManager> {
51        self.session_manager.clone()
52    }
53
54    pub fn group_manager(&self) -> GroupManager {
55        self.session_manager.group_manager()
56    }
57}
58
59#[cfg_attr(feature = "frb-api", frb(ignore))]
60impl Client {
61    /// Get access to the multi-relay message manager
62    pub fn message_manager(&self) -> &Arc<ZoeClientMessageManager> {
63        &self.message_manager
64    }
65
66    /// Get access to the multi-relay blob service
67    pub fn blob_service(&self) -> &Arc<ZoeClientBlobService> {
68        &self.blob_service
69    }
70
71    /// Get access to storage
72    pub fn storage(&self) -> &Arc<ZoeClientStorage> {
73        &self.storage
74    }
75
76    /// Get the client's public key
77    pub fn public_key(&self) -> VerifyingKey {
78        self.client_secret.inner_keypair.public_key()
79    }
80
81    /// Get the client's keypair
82    pub fn keypair(&self) -> &Arc<KeyPair> {
83        &self.client_secret.inner_keypair
84    }
85    /// Get a reference to the blob client for advanced operations
86    ///
87    /// This provides direct access to the underlying blob storage client
88    /// for operations not covered by the high-level file storage API.
89    ///
90    /// # Returns
91    ///
92    /// A reference to the `BlobClient`
93    pub fn blob_client(&self) -> &BlobClient {
94        self.fs.blob_client()
95    }
96}