ipmail 0.1.0

Rust implementation of SP-centric decentralized instant message synchronization protocol(DIMSP)
Documentation
use std::{future::Future, io::Result, time::Duration};

use libipld::Cid;

use crate::{account::MNSAccount, fs::IpldFS};

/// Sync protocol client trait
pub trait SyncClient {
    type Sync<'cx>: Future<Output = Result<()>> + Send + Unpin + 'cx
    where
        Self: 'cx;

    /// Sync [`MailContent`](super::mail::MailContent) and all related multiparts from [`MNSAccount`]
    fn sync<'cx, 'a, FS: IpldFS>(
        &'a mut self,
        cid: Cid,
        from: MNSAccount,
        fs: &'cx mut FS,
    ) -> Self::Sync<'cx>
    where
        'a: 'cx;
}

/// Sync protocol server trait.
pub trait SyncServer {
    /// Handle incoming sync request.
    fn run_once<FS: IpldFS>(&mut self, fs: &mut FS, timeout: Duration) -> Result<()>;
}