Warning fixups

This commit is contained in:
Jazz Turner-Baggs 2026-04-28 08:06:19 -07:00
parent da7e06e495
commit 94a2904c0e
No known key found for this signature in database
10 changed files with 39 additions and 21 deletions

1
Cargo.lock generated
View File

@ -364,6 +364,7 @@ name = "client"
version = "0.1.0"
dependencies = [
"chat-sqlite",
"components",
"libchat",
"tempfile",
"thiserror",

View File

@ -22,12 +22,15 @@ default-members = [
"core/double-ratchets",
"core/storage",
"core/integration_tests_core",
"crates/client",
"crates/client-ffi",
]
[workspace.dependencies]
blake2 = "0.10"
crypto = { path = "core/crypto" }
crypto = { path = "core/crypto" }
libchat = { path = "core/conversations" }
logoschat_components = {package="components", path ="extensions/components"}
sqlite = { path = "core/sqlite"}
storage = { path = "core/storage" }

View File

@ -78,7 +78,7 @@ where
.map_err(ChatError::generic)?;
Ok(Self {
identity: identity,
identity,
ds,
store,
inbox,
@ -319,7 +319,6 @@ where
}
}
#[allow(unused)] // Temporary until GroupIntegration is completed
fn load_group_convo(
&mut self,
convo_id: ConversationId,

View File

@ -172,9 +172,9 @@ where
}
fn subscribe(ds: &mut DS, convo_id: &str) -> Result<(), ChatError> {
ds.subscribe(&Self::delivery_address_from_id(&convo_id))
ds.subscribe(&Self::delivery_address_from_id(convo_id))
.map_err(ChatError::generic)?;
ds.subscribe(&Self::ctrl_delivery_address_from_id(&convo_id))
ds.subscribe(&Self::ctrl_delivery_address_from_id(convo_id))
.map_err(ChatError::generic)?;
Ok(())

View File

@ -50,13 +50,13 @@ impl MlsContext for PqMlsContext {
};
let envelope = EnvelopeV1 {
conversation_hint: ProtocolParams::conversation_id_for_account_id(&account_id),
conversation_hint: ProtocolParams::conversation_id_for_account_id(account_id),
salt: 0,
payload: frame.encode_to_vec().into(),
};
let outbound_msg = AddressedEnvelope {
delivery_address: ProtocolParams::delivery_address_for_account_id(&account_id),
delivery_address: ProtocolParams::delivery_address_for_account_id(account_id),
data: envelope.encode_to_vec(),
};

View File

@ -14,6 +14,8 @@ pub type DeliverFn = Option<
) -> i32,
>;
#[derive(Debug)]
pub struct CDelivery {
pub callback: DeliverFn,
}
@ -28,4 +30,8 @@ impl DeliveryService for CDelivery {
let rc = unsafe { cb(addr.as_ptr(), addr.len(), data.as_ptr(), data.len()) };
if rc < 0 { Err(rc) } else { Ok(()) }
}
fn subscribe(&mut self, _delivery_address: &str) -> Result<(), Self::Error> {
todo!()
}
}

View File

@ -8,6 +8,7 @@ crate-type = ["rlib"]
[dependencies]
libchat = { workspace = true }
logoschat_components = { workspace = true}
chat-sqlite = { path = "../../core/sqlite" }
thiserror = "2"

View File

@ -1,22 +1,23 @@
use libchat::{
AddressedEnvelope, ChatError, ChatStorage, ContentData, Context, ConversationIdOwned, RegistrationService
DeliveryService, Introduction, StorageConfig,
AddressedEnvelope, ChatError, ChatStorage, ContentData, Context, ConversationIdOwned,
DeliveryService, Introduction, RegistrationService, StorageConfig,
};
use logoschat_components::EphemeralRegistry;
use crate::errors::ClientError;
pub struct ChatClient<D: DeliveryService> {
ctx: Context<D, EphemeralChatStorage>,
delivery: D,
pub struct ChatClient<D: DeliveryService + 'static> {
ctx: Context<D, EphemeralRegistry, ChatStorage>,
}
impl<D: DeliveryService, RS: RegistrationService, > ChatClient<D> {
impl<D: DeliveryService> ChatClient<D> {
/// Create an in-memory, ephemeral client. Identity is lost on drop.
pub fn new(name: impl Into<String>, delivery: D) -> Self {
let registry = EphemeralRegistry::new();
let store = ChatStorage::in_memory();
Self {
ctx: Context::new_with_name(name, store),
delivery,
ctx: Context::new_with_name(name, delivery, registry, store).unwrap(),
}
}
@ -30,8 +31,9 @@ impl<D: DeliveryService, RS: RegistrationService, > ChatClient<D> {
delivery: D,
) -> Result<Self, ClientError<D::Error>> {
let store = ChatStorage::new(config).map_err(ChatError::from)?;
let ctx = Context::new_from_store(name, store)?;
Ok(Self { ctx, delivery })
let registry = EphemeralRegistry::new();
let ctx = Context::new_from_store(name, delivery, registry, store)?;
Ok(Self { ctx })
}
/// Returns the installation name (identity label) of this client.
@ -86,7 +88,8 @@ impl<D: DeliveryService, RS: RegistrationService, > ChatClient<D> {
envelopes: Vec<AddressedEnvelope>,
) -> Result<(), ClientError<D::Error>> {
for env in envelopes {
self.delivery.publish(env).map_err(ClientError::Delivery)?;
let mut delivery = self.ctx.ds();
delivery.publish(env).map_err(ClientError::Delivery)?;
}
Ok(())
}

View File

@ -10,7 +10,7 @@ type Message = Vec<u8>;
/// Messages are stored in an append-only log per delivery address. Readers hold
/// independent [`Cursor`]s and advance their position without consuming messages,
/// so multiple consumers on the same address each see every message.
#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
pub struct MessageBus {
log: Arc<RwLock<HashMap<String, Vec<Message>>>>,
}
@ -80,7 +80,7 @@ impl Iterator for Cursor {
/// clients can share one logical delivery service. Construct with a
/// [`MessageBus`] and use [`cursor`](InProcessDelivery::cursor) /
/// [`cursor_at_tail`](InProcessDelivery::cursor_at_tail) to read messages.
#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
pub struct InProcessDelivery(MessageBus);
impl InProcessDelivery {
@ -108,4 +108,9 @@ impl DeliveryService for InProcessDelivery {
self.0.push(envelope.delivery_address, envelope.data);
Ok(())
}
fn subscribe(&mut self, _delivery_address: &str) -> Result<(), Self::Error> {
// TODO: (P1) implement subscribe
Ok(())
}
}

View File

@ -1,7 +1,7 @@
use libchat::ChatError;
#[derive(Debug, thiserror::Error)]
pub enum ClientError<D: std::fmt::Debug> {
pub enum ClientError<D: std::fmt::Display> {
#[error(transparent)]
Chat(#[from] ChatError),
/// Crypto state advanced but at least one envelope failed delivery.