use mnesis::AggregateRoot;
use mnesis::Events;
use mnesis::VersionedEvent;
use mnesis::*;
use static_assertions::*;
use std::fmt;
assert_eq_size!(Version, u64);
assert_impl_all!(Version: Copy, Clone, Eq, Ord, std::hash::Hash);
assert_impl_all!(Version: Send, Sync);
assert_impl_all!(Version: fmt::Display, fmt::Debug);
assert_impl_all!(KernelError: std::error::Error, Send, Sync, fmt::Debug, fmt::Display);
assert_impl_all!(VersionedEvent<u8>: Send, Sync);
assert_impl_all!(VersionedEvent<String>: Send, Sync);
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct StaticId(String);
impl fmt::Display for StaticId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl AsRef<[u8]> for StaticId {
fn as_ref(&self) -> &[u8] {
self.0.as_bytes()
}
}
assert_impl_all!(StaticId: Id);
#[derive(Debug, Clone)]
#[allow(dead_code, reason = "test-only event type used for static assertions")]
enum StaticEvent {
A,
}
impl Message for StaticEvent {}
impl DomainEvent for StaticEvent {
fn name(&self) -> &'static str {
"A"
}
}
#[derive(Default, Debug, Clone)]
struct StaticState;
impl AggregateState for StaticState {
type Event = StaticEvent;
fn initial() -> Self {
Self
}
fn apply(self, _event: &StaticEvent) -> Self {
self
}
}
#[derive(Debug, thiserror::Error)]
#[error("static error")]
struct StaticError;
#[derive(Debug)]
struct StaticAggregate;
impl Aggregate for StaticAggregate {
type State = StaticState;
type Error = StaticError;
type Id = StaticId;
}
assert_impl_all!(AggregateRoot<StaticAggregate>: Send, Sync, fmt::Debug);
assert_impl_all!(Events<StaticEvent>: Send, Sync, fmt::Debug);
#[test]
fn static_assertions_compile() {
}