#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
mod id;
mod uuid_allocator;
use std::fmt::Debug;
use std::hash::Hash;
pub use id::Id;
pub use uuid_allocator::UuidAllocator;
pub type DefaultIdAllocator = UuidAllocator;
#[derive(Debug)]
pub struct IdentityError(pub &'static str);
pub trait Identity<T: ?Sized, Type> {
fn get_value(&self) -> Type;
}
pub trait Identifiable<T: ?Sized, Type> {
type Id: Identity<Self, Type> + ?Sized;
fn get_id(&self) -> Self::Id;
}
pub trait Record: Clone {
type Allocator: TemporaryIdAllocator;
fn get_id(&self) -> Id<Self>;
fn set_permanent_id(&mut self, value: <Self::Allocator as TemporaryIdAllocator>::Type) -> Result<(), IdentityError>;
}
pub trait TemporaryIdAllocator: Clone + Debug {
type Type: Copy + PartialEq + Hash + Eq + std::fmt::Debug;
fn new_id() -> Self::Type;
}