ScimVersion

Struct ScimVersion 

Source
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>

Source

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);
Source

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");
Source

pub fn as_str(&self) -> &str

Get the opaque version string.

This is primarily for internal use and debugging. The opaque string should not be relied upon for any business logic outside of equality comparisons.

Trait Implementations§

Source§

impl<Format: Clone> Clone for ScimVersion<Format>

Source§

fn clone(&self) -> ScimVersion<Format>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Format: Debug> Debug for ScimVersion<Format>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, Format> Deserialize<'de> for ScimVersion<Format>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ScimVersion<Http>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ScimVersion<Raw>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ScimVersion<Http>> for ScimVersion<Raw>

Source§

fn from(http: ScimVersion<Http>) -> Self

Converts to this type from the input type.
Source§

impl From<ScimVersion<Raw>> for ScimVersion<Http>

Source§

fn from(raw: ScimVersion<Raw>) -> Self

Converts to this type from the input type.
Source§

impl FromStr for ScimVersion<Http>

Source§

type Err = VersionError

The associated error which can be returned from parsing.
Source§

fn from_str(etag_header: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for ScimVersion<Raw>

Source§

type Err = VersionError

The associated error which can be returned from parsing.
Source§

fn from_str(version_str: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<Format: Hash> Hash for ScimVersion<Format>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<F1, F2> PartialEq<ScimVersion<F2>> for ScimVersion<F1>

Source§

fn eq(&self, other: &ScimVersion<F2>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Format> Serialize for ScimVersion<Format>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TenantValidator for T

Source§

fn validate_tenant_context( &self, expected_tenant_id: &str, context: &RequestContext, ) -> Result<(), String>

Validate that the context has the expected tenant.
Source§

fn validate_single_tenant_context( &self, context: &RequestContext, ) -> Result<(), String>

Validate that the context is for single-tenant operation.
Source§

fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>

Extract tenant context or return error for multi-tenant operations.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,