//! IDs used for data objects and models. //! //! UUID is always unique; the numeric ID used as a fallback //! is auto-incrementing, but some values may be skipped. //! //! It is better to treat both ID implementations as opaque. #[cfg(feature = "uuid-ids")] #[allow(non_camel_case_types)] pub type ID = uuid::Uuid; #[cfg(not(feature = "uuid-ids"))] #[allow(non_camel_case_types)] pub type ID = u32; /// Something that has ID pub trait HaveId { fn get_id(&self) -> ID; } #[cfg(feature = "uuid-ids")] #[cfg(test)] pub fn random_id() -> ID { ID::new_v4() } #[cfg(not(feature = "uuid-ids"))] #[cfg(test)] pub fn random_id() -> ID { use rand::Rng; rand::thread_rng().gen() }