chore: isolate ffi functions

This commit is contained in:
kaichaosun 2026-02-03 14:53:55 +08:00
parent 2e48e49a9a
commit 0ca0bb9548
No known key found for this signature in database
GPG Key ID: 223E0F992F4F03BF
9 changed files with 15 additions and 14 deletions

View File

@ -1,7 +1,7 @@
use std::{collections::HashMap, rc::Rc, sync::Arc}; use std::{collections::HashMap, rc::Rc, sync::Arc};
use crate::{ use crate::{
dm::common::{HasConversationId, OutboundSession, SessionRegistry}, common::{HasConversationId, OutboundSession, SessionRegistry},
errors::ChatError, errors::ChatError,
identity::Identity, identity::Identity,
inbox::Inbox, inbox::Inbox,

View File

@ -1,2 +1 @@
pub mod common;
pub mod privatev1; pub mod privatev1;

View File

@ -6,7 +6,7 @@ use crypto::SecretKey;
use prost::{Message, bytes::Bytes}; use prost::{Message, bytes::Bytes};
use crate::{ use crate::{
dm::common::{HasConversationId, OutboundSession, SessionId}, common::{HasConversationId, OutboundSession, SessionId},
errors::ChatError, errors::ChatError,
types::AddressedEncryptedPayload, types::AddressedEncryptedPayload,
utils::timestamp_millis, utils::timestamp_millis,

View File

@ -0,0 +1 @@
pub mod api;

View File

@ -7,8 +7,8 @@ use std::rc::Rc;
use crypto::{PrekeyBundle, SecretKey}; use crypto::{PrekeyBundle, SecretKey};
use crate::common::{HasConversationId, InboundSessionHandler, OutboundSession, SessionId};
use crate::context::Introduction; use crate::context::Introduction;
use crate::dm::common::{HasConversationId, InboundSessionHandler, OutboundSession, SessionId};
use crate::dm::privatev1::PrivateV1Convo; use crate::dm::privatev1::PrivateV1Convo;
use crate::errors::ChatError; use crate::errors::ChatError;
use crate::identity::Identity; use crate::identity::Identity;

View File

@ -1,20 +1,23 @@
mod api; pub mod common;
mod context;
pub mod dm; pub mod dm;
mod errors; pub mod ffi;
mod group; pub mod group;
mod identity;
pub mod inbox; pub mod inbox;
mod context;
mod errors;
mod identity;
mod proto; mod proto;
mod types; mod types;
mod utils; mod utils;
pub use api::*;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use crate::ffi::api::{
create_context, create_intro_bundle, create_new_private_convo, destroy_context,
handle_payload,
};
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]

View File

@ -1,7 +1,5 @@
use crate::proto::{self, Message}; use crate::proto::{self, Message};
// FFI Type definitions
// This struct represents Outbound data. // This struct represents Outbound data.
// It wraps an encoded payload with a delivery address, so it can be handled by the delivery service. // It wraps an encoded payload with a delivery address, so it can be handled by the delivery service.
pub struct AddressedEnvelope { pub struct AddressedEnvelope {