pub struct ScimVersion<Format> { /* private fields */ }Expand description
Opaque version identifier for SCIM resources with compile-time format safety.
This type uses phantom types to distinguish between HTTP ETag format and raw internal format at compile time, preventing format confusion and runtime errors. The internal representation remains opaque to prevent direct manipulation.
Versions can be created from:
- Provider-specific identifiers (database sequence numbers, timestamps, etc.)
- Content hashes (for stateless version generation)
- String parsing with automatic format detection
§Type Safety
The phantom type parameter prevents mixing formats accidentally:
use scim_server::resource::version::{RawVersion, HttpVersion};
let raw_version = RawVersion::from_hash("123");
let http_version: HttpVersion = "W/\"456\"".parse().unwrap();
// This won't compile - cannot pass HttpVersion where RawVersion expected
some_function_expecting_raw(http_version);§Examples
use scim_server::resource::version::{RawVersion, HttpVersion};
// From hash string (always produces Raw format)
let raw_version = RawVersion::from_hash("12345");
// From content hash (always produces Raw format)
let content = br#"{"id":"123","name":"John Doe"}"#;
let hash_version = RawVersion::from_content(content);
// Parse from strings with format detection
let raw_parsed: RawVersion = "abc123def".parse().unwrap();
let http_parsed: HttpVersion = "\"abc123def\"".parse().unwrap();Implementations§
Source§impl<Format> ScimVersion<Format>
impl<Format> ScimVersion<Format>
Sourcepub fn from_content(content: &[u8]) -> RawVersion
pub fn from_content(content: &[u8]) -> RawVersion
Create a version from resource content.
This generates a deterministic hash-based version from the resource content, ensuring universal compatibility across all provider implementations. The version is based on the full resource content including all fields.
Always produces a RawVersion as content hashing creates canonical versions.
§Arguments
content- The complete resource content as bytes
§Examples
use scim_server::resource::version::RawVersion;
let resource_json = br#"{"id":"123","userName":"john.doe"}"#;
let version = RawVersion::from_content(resource_json);Sourcepub fn from_hash(hash_string: impl AsRef<str>) -> RawVersion
pub fn from_hash(hash_string: impl AsRef<str>) -> RawVersion
Create a version from a pre-computed hash string.
This is useful for provider-specific versioning schemes such as database sequence numbers, timestamps, or UUIDs. The provider can use any string as a version identifier.
Always produces a RawVersion as the canonical internal format.
§Arguments
hash_string- Provider-specific version identifier
§Examples
use scim_server::resource::version::RawVersion;
// Database sequence number
let db_version = RawVersion::from_hash("seq_12345");
// Timestamp-based version
let time_version = RawVersion::from_hash("1703123456789");
// UUID-based version
let uuid_version = RawVersion::from_hash("550e8400-e29b-41d4-a716-446655440000");Trait Implementations§
Source§impl<Format: Clone> Clone for ScimVersion<Format>
impl<Format: Clone> Clone for ScimVersion<Format>
Source§fn clone(&self) -> ScimVersion<Format>
fn clone(&self) -> ScimVersion<Format>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Format: Debug> Debug for ScimVersion<Format>
impl<Format: Debug> Debug for ScimVersion<Format>
Source§impl<'de, Format> Deserialize<'de> for ScimVersion<Format>
impl<'de, Format> Deserialize<'de> for ScimVersion<Format>
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>,
Source§impl Display for ScimVersion<Http>
impl Display for ScimVersion<Http>
Source§impl Display for ScimVersion<Raw>
impl Display for ScimVersion<Raw>
Source§impl From<ScimVersion<Http>> for ScimVersion<Raw>
impl From<ScimVersion<Http>> for ScimVersion<Raw>
Source§fn from(http: ScimVersion<Http>) -> Self
fn from(http: ScimVersion<Http>) -> Self
Source§impl From<ScimVersion<Raw>> for ScimVersion<Http>
impl From<ScimVersion<Raw>> for ScimVersion<Http>
Source§fn from(raw: ScimVersion<Raw>) -> Self
fn from(raw: ScimVersion<Raw>) -> Self
Source§impl FromStr for ScimVersion<Http>
impl FromStr for ScimVersion<Http>
Source§impl FromStr for ScimVersion<Raw>
impl FromStr for ScimVersion<Raw>
Source§impl<Format: Hash> Hash for ScimVersion<Format>
impl<Format: Hash> Hash for ScimVersion<Format>
Source§impl<F1, F2> PartialEq<ScimVersion<F2>> for ScimVersion<F1>
impl<F1, F2> PartialEq<ScimVersion<F2>> for ScimVersion<F1>
Source§impl<Format> Serialize for ScimVersion<Format>
impl<Format> Serialize for ScimVersion<Format>
impl<Format: Eq> Eq for ScimVersion<Format>
Auto Trait Implementations§
impl<Format> Freeze for ScimVersion<Format>
impl<Format> RefUnwindSafe for ScimVersion<Format>where
Format: RefUnwindSafe,
impl<Format> Send for ScimVersion<Format>where
Format: Send,
impl<Format> Sync for ScimVersion<Format>where
Format: Sync,
impl<Format> Unpin for ScimVersion<Format>where
Format: Unpin,
impl<Format> UnwindSafe for ScimVersion<Format>where
Format: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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