radicle-feed 0.1.2

A Radicle feed library for implementing Radicle COB feeds
Documentation
pub mod entry;
pub mod error;
pub mod feed;
pub mod storage;

// Re-export commonly used types
pub use entry::{ActionEntry, Author};
pub use feed::{FeedProcessor, ProcessingStats};
pub use storage::{FeedStorage, MemoryStorage, StorageStats};

// Version information
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg(test)]
mod tests {
    use std::str::FromStr;

    use radicle::{
        cob::{ObjectId, Timestamp, TypeName},
        git::Oid,
        node::Alias,
        prelude::{Did, RepoId},
    };

    use super::*;

    #[test]
    fn test_memory_storage() {
        let storage = MemoryStorage::new();
        let stats = storage.get_stats().unwrap();
        assert_eq!(stats.total_actions, 0);
    }

    #[test]
    fn test_memory_insert_batch() {
        let mut storage = MemoryStorage::new();

        storage
            .insert_batch(&[
                ActionEntry {
                    operation_id: Oid::from_str("4ec0362610c1df9be322d82b4514933de7e0e587")
                        .unwrap(),
                    cob_id: ObjectId::from_str("4ec0362610c1df9be322d82b4514933de7e0e587").unwrap(),
                    rid: RepoId::from_str("rad:z281hhqRHPQ1sop3irVT451vNY68i").unwrap(),
                    timestamp: Timestamp::from_secs(1760362137),
                    action: "action".to_string(),
                    author: Author {
                        did: Did::from_str(
                            "did:key:z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5",
                        )
                        .unwrap(),
                        alias: Alias::from_str("alice").ok(),
                    },
                    typename: TypeName::from_str("xyz.radicle.issue").unwrap(),
                },
                ActionEntry {
                    operation_id: Oid::from_str("49458fc9b9bb2e3138b1ceda59944c9f200bbc08")
                        .unwrap(),
                    cob_id: ObjectId::from_str("49458fc9b9bb2e3138b1ceda59944c9f200bbc08").unwrap(),
                    rid: RepoId::from_str("rad:z281hhqRHPQ1sop3irVT451vNY68i").unwrap(),
                    timestamp: Timestamp::from_secs(1760362137),
                    action: "action".to_string(),
                    author: Author {
                        did: Did::from_str(
                            "did:key:z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5",
                        )
                        .unwrap(),
                        alias: Alias::from_str("alice").ok(),
                    },
                    typename: TypeName::from_str("xyz.radicle.issue").unwrap(),
                },
            ])
            .unwrap();

        let stats = storage.get_stats().unwrap();
        assert_eq!(stats.total_actions, 2);
    }
}