chore: fix dead code

This commit is contained in:
kaichaosun 2026-02-03 13:21:50 +08:00
parent 2a9fe1c8e5
commit 572ae6d954
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
6 changed files with 9 additions and 28 deletions

View File

@ -23,7 +23,6 @@ pub struct Context {
_identity: Rc<Identity>,
store: SessionRegistry,
inbox: Inbox,
buf_size: usize,
convo_handle_map: HashMap<u32, Arc<str>>,
next_convo_handle: ConvoHandle,
}
@ -36,20 +35,11 @@ impl Context {
_identity: identity,
store: SessionRegistry::new(),
inbox,
buf_size: 0,
convo_handle_map: HashMap::new(),
next_convo_handle: INITIAL_CONVO_HANDLE,
}
}
pub fn buffer_size(&self) -> usize {
self.buf_size
}
pub fn set_buffer_size(&mut self, size: usize) {
self.buf_size = size
}
pub fn create_private_convo(
&mut self,
remote_bundle: &Introduction,

View File

@ -12,7 +12,6 @@ pub trait HasConversationId: Debug {
fn id(&self) -> SessionId<'_>;
}
#[allow(dead_code)]
pub trait InboundSessionHandler: HasConversationId + Debug {
fn handle_frame(
&mut self,
@ -27,13 +26,11 @@ pub trait OutboundSession: HasConversationId + Debug {
fn remote_id(&self) -> String;
}
#[allow(dead_code)]
pub struct SessionRegistry {
sessions: HashMap<Arc<str>, Box<dyn OutboundSession>>,
handlers: HashMap<Arc<str>, Box<dyn InboundSessionHandler>>,
}
#[allow(dead_code)]
impl SessionRegistry {
pub fn new() -> Self {
Self {

View File

@ -1,5 +1,3 @@
pub use blake2::Digest;
use blake2::{Blake2b, digest};
use prost::bytes::Bytes;
pub use x25519_dalek::{PublicKey, StaticSecret};
@ -12,6 +10,3 @@ impl CopyBytes for PublicKey {
Bytes::copy_from_slice(self.as_bytes())
}
}
#[allow(dead_code)]
pub type Blake2b128 = Blake2b<digest::consts::U16>;

View File

@ -141,6 +141,7 @@ impl Inbox {
payload: proto::EncryptedPayload,
) -> Result<(SecretKey, proto::InboxV1Frame), ChatError> {
let handshake = Self::extract_payload(payload)?;
let payload_bytes = handshake.payload.clone();
let header = handshake
.header
.ok_or(ChatError::UnexpectedPayload("InboxV1Header".into()))?;
@ -166,8 +167,7 @@ impl Inbox {
&initator_ephemeral,
);
// TODO: Decrypt Content
let frame = proto::InboxV1Frame::decode(handshake.payload)?;
let frame = Self::decrypt_frame(payload_bytes)?;
Ok((seed_key, frame))
}
@ -183,12 +183,9 @@ impl Inbox {
Ok(handshake)
}
fn decrypt_frame(
enc_payload: proto::InboxHandshakeV1,
) -> Result<proto::InboxV1Frame, ChatError> {
let frame_bytes = enc_payload.payload;
fn decrypt_frame(payload_bytes: prost::bytes::Bytes) -> Result<proto::InboxV1Frame, ChatError> {
// TODO: decrypt payload
let frame = proto::InboxV1Frame::decode(frame_bytes)?;
let frame = proto::InboxV1Frame::decode(payload_bytes)?;
Ok(frame)
}

View File

@ -1,15 +1,17 @@
mod api;
mod context;
mod conversation;
pub mod conversation;
mod crypto;
mod errors;
mod identity;
mod inbox;
pub mod inbox;
mod proto;
mod types;
mod utils;
pub use api::*;
pub use conversation::common::{HasConversationId, InboundSessionHandler, OutboundSession};
pub use inbox::Inbox;
#[cfg(test)]
mod tests {

View File

@ -19,7 +19,7 @@ pub struct ContentData {
// Internal type Definitions
// Used by Conversations to attach addresses to outbound encrypted payloads
pub(crate) struct AddressedEncryptedPayload {
pub struct AddressedEncryptedPayload {
pub delivery_address: String,
pub data: proto::EncryptedPayload,
}