pub enum ConditionalResult<T> {
Success(T),
VersionMismatch(VersionConflict),
NotFound,
}
Expand description
Result type for conditional SCIM operations.
Represents the outcome of a conditional operation that depends on resource versioning. This allows providers to indicate whether an operation succeeded, failed due to a version mismatch, or failed because the resource was not found.
§Examples
use scim_server::resource::version::{ConditionalResult, RawVersion, VersionConflict};
use serde_json::json;
// Successful operation
let success = ConditionalResult::Success(json!({"id": "123"}));
// Version mismatch
let expected = RawVersion::from_hash("1");
let current = RawVersion::from_hash("2");
let conflict: ConditionalResult<serde_json::Value> = ConditionalResult::VersionMismatch(VersionConflict {
expected: expected.into(),
current: current.into(),
message: "Resource was modified by another client".to_string(),
});
// Resource not found
let not_found: ConditionalResult<serde_json::Value> = ConditionalResult::NotFound;
Variants§
Success(T)
Operation completed successfully
VersionMismatch(VersionConflict)
Operation failed due to version mismatch
NotFound
Operation failed because the resource was not found
Implementations§
Source§impl<T> ConditionalResult<T>
impl<T> ConditionalResult<T>
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if the result represents a successful operation.
Sourcepub fn is_version_mismatch(&self) -> bool
pub fn is_version_mismatch(&self) -> bool
Check if the result represents a version mismatch.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Check if the result represents a not found error.
Sourcepub fn into_success(self) -> Option<T>
pub fn into_success(self) -> Option<T>
Extract the success value, if present.
Sourcepub fn into_version_conflict(self) -> Option<VersionConflict>
pub fn into_version_conflict(self) -> Option<VersionConflict>
Extract the version conflict, if present.
Sourcepub fn map<U, F>(self, f: F) -> ConditionalResult<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> ConditionalResult<U>where
F: FnOnce(T) -> U,
Map the success value to a different type.
Trait Implementations§
Source§impl<T: Clone> Clone for ConditionalResult<T>
impl<T: Clone> Clone for ConditionalResult<T>
Source§fn clone(&self) -> ConditionalResult<T>
fn clone(&self) -> ConditionalResult<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for ConditionalResult<T>
impl<T: Debug> Debug for ConditionalResult<T>
Source§impl<T: PartialEq> PartialEq for ConditionalResult<T>
impl<T: PartialEq> PartialEq for ConditionalResult<T>
impl<T> StructuralPartialEq for ConditionalResult<T>
Auto Trait Implementations§
impl<T> Freeze for ConditionalResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for ConditionalResult<T>where
T: RefUnwindSafe,
impl<T> Send for ConditionalResult<T>where
T: Send,
impl<T> Sync for ConditionalResult<T>where
T: Sync,
impl<T> Unpin for ConditionalResult<T>where
T: Unpin,
impl<T> UnwindSafe for ConditionalResult<T>where
T: 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
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> 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>
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 moreSource§impl<T> TenantValidator for T
impl<T> TenantValidator for T
Source§fn validate_tenant_context(
&self,
expected_tenant_id: &str,
context: &RequestContext,
) -> Result<(), String>
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>
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>
fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
Extract tenant context or return error for multi-tenant operations.