ConditionalResult

Enum ConditionalResult 

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

Source

pub fn is_success(&self) -> bool

Check if the result represents a successful operation.

Source

pub fn is_version_mismatch(&self) -> bool

Check if the result represents a version mismatch.

Source

pub fn is_not_found(&self) -> bool

Check if the result represents a not found error.

Source

pub fn into_success(self) -> Option<T>

Extract the success value, if present.

Source

pub fn into_version_conflict(self) -> Option<VersionConflict>

Extract the version conflict, if present.

Source

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>

Source§

fn clone(&self) -> ConditionalResult<T>

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<T: Debug> Debug for ConditionalResult<T>

Source§

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

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

impl<T: PartialEq> PartialEq for ConditionalResult<T>

Source§

fn eq(&self, other: &ConditionalResult<T>) -> 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<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> 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<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, 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> ErasedDestructor for T
where T: 'static,