Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/chat-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ fn run<T: Transport>(transport: T, cli: &Cli) -> Result<()> {
let (client, events) = ChatClientBuilder::new()
.transport(transport)
.storage_config(storage)
.map_err(|e| anyhow::anyhow!("{e:?}"))?
.registration(registry)
.build()
.map_err(|e| anyhow::anyhow!("{e:?}"))
Expand All @@ -129,6 +130,7 @@ fn run<T: Transport>(transport: T, cli: &Cli) -> Result<()> {
let (client, events) = ChatClientBuilder::new()
.transport(transport)
.storage_config(storage)
.map_err(|e| anyhow::anyhow!("{e:?}"))?
.build()
.map_err(|e| anyhow::anyhow!("{e:?}"))
.context("failed to open chat client")?;
Expand Down Expand Up @@ -197,6 +199,7 @@ fn run_logos_delivery(cli: Cli) -> Result<()> {
path: db_str,
key: "chat-cli".to_string(),
})
.map_err(|e| anyhow::anyhow!("{e:?}"))?
.transport(delivery)
.build()
.map_err(|e| anyhow::anyhow!("{e:?}"))
Expand Down
13 changes: 7 additions & 6 deletions crates/client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,18 @@ impl<I, T, R, S> ChatClientBuilder<I, T, R, S> {
}
}

pub fn storage_config(self, config: StorageConfig) -> ChatClientBuilder<I, T, R, ChatStorage> {
let storage = ChatStorage::new(config)
.map_err(ChatError::from)
.expect("Storage config file should be valid");
pub fn storage_config(
self,
config: StorageConfig,
) -> Result<ChatClientBuilder<I, T, R, ChatStorage>, ChatError> {
let storage = ChatStorage::new(config).map_err(ChatError::from)?;

ChatClientBuilder {
Ok(ChatClientBuilder {
ident: self.ident,
transport: self.transport,
registration: self.registration,
storage,
}
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use event::{Event, MessageSender};

// Re-export types callers need to interact with ChatClient.
pub use libchat::{
AddressedEnvelope, ChatStore, ConversationClass, ConversationId, DeliveryService,
AddressedEnvelope, ChatStorage, ChatStore, ConversationClass, ConversationId, DeliveryService,
IdentityProvider, RegistrationService, StorageConfig,
};

Expand Down