pub struct RegionID { /* private fields */ }Expand description
Unique identifier for a brain region, based on UUID v7.
This struct provides type safety and ensures global uniqueness for brain region IDs. UUID v7 is time-ordered, which provides better database indexing and sortability. It handles serialization to and deserialization from string representations of UUIDs.
§Examples
use feagi_structures::genomic::brain_regions::RegionID;
// Generate a new time-ordered RegionID
let region_id = RegionID::new();
// Convert to string for storage/display
let id_string = region_id.to_string();
// Parse from string
let parsed_id = RegionID::from_string(&id_string).unwrap();
assert_eq!(region_id, parsed_id);Implementations§
Source§impl RegionID
impl RegionID
Sourcepub fn new() -> Self
pub fn new() -> Self
Generates a new, time-ordered RegionID (UUID v7).
UUID v7 uses a timestamp-based approach, providing natural sorting and better database performance compared to random UUIDs.
§Examples
use feagi_structures::genomic::brain_regions::RegionID;
let region_id = RegionID::new();
assert_ne!(region_id.to_string(), "");Sourcepub fn from_uuid(uuid: Uuid) -> Self
pub fn from_uuid(uuid: Uuid) -> Self
Creates a RegionID from a UUID.
§Examples
use feagi_structures::genomic::brain_regions::RegionID;
use uuid::Uuid;
let uuid = Uuid::now_v7();
let region_id = RegionID::from_uuid(uuid);
assert_eq!(region_id.as_uuid(), uuid);Sourcepub fn from_string(s: &str) -> Result<Self, FeagiDataError>
pub fn from_string(s: &str) -> Result<Self, FeagiDataError>
Tries to create a RegionID from a string.
Returns an error if the string is not a valid UUID.
§Examples
use feagi_structures::genomic::brain_regions::RegionID;
let region_id = RegionID::from_string("550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(region_id.to_string(), "550e8400-e29b-41d4-a716-446655440000");Trait Implementations§
Source§impl<'de> Deserialize<'de> for RegionID
impl<'de> Deserialize<'de> for RegionID
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for RegionID
impl Eq for RegionID
impl StructuralPartialEq for RegionID
Auto Trait Implementations§
impl Freeze for RegionID
impl RefUnwindSafe for RegionID
impl Send for RegionID
impl Sync for RegionID
impl Unpin for RegionID
impl UnwindSafe for RegionID
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more