2026-04-03 08:25:26 +08:00
|
|
|
use chat_sqlite::StorageConfig;
|
2026-03-24 18:21:00 -07:00
|
|
|
use libchat::ChatError;
|
2026-04-03 08:25:26 +08:00
|
|
|
use libchat::ChatStorage;
|
2026-03-24 18:21:00 -07:00
|
|
|
use libchat::Context;
|
|
|
|
|
|
|
|
|
|
pub struct ChatClient {
|
2026-04-03 08:25:26 +08:00
|
|
|
ctx: Context<ChatStorage>,
|
2026-03-24 18:21:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ChatClient {
|
|
|
|
|
pub fn new(name: impl Into<String>) -> Self {
|
2026-04-03 08:25:26 +08:00
|
|
|
let store =
|
|
|
|
|
ChatStorage::new(StorageConfig::InMemory).expect("in-memory storage should not fail");
|
2026-03-24 18:21:00 -07:00
|
|
|
Self {
|
2026-04-03 08:25:26 +08:00
|
|
|
ctx: Context::new_with_name(name, store),
|
2026-03-24 18:21:00 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn create_bundle(&mut self) -> Result<Vec<u8>, ChatError> {
|
|
|
|
|
self.ctx.create_intro_bundle()
|
|
|
|
|
}
|
|
|
|
|
}
|