pub struct MandateUseCases { /* private fields */ }Implementations§
Source§impl MandateUseCases
impl MandateUseCases
pub fn new(repo: Arc<dyn MandateRepository>) -> Self
Sourcepub async fn issue(
&self,
subject_user_id: Uuid,
kind: MandateKind,
scope: MandateScope,
issued_by: Uuid,
reason: String,
valid_from: DateTime<Utc>,
valid_until: DateTime<Utc>,
) -> Result<Mandate, AppError>
pub async fn issue( &self, subject_user_id: Uuid, kind: MandateKind, scope: MandateScope, issued_by: Uuid, reason: String, valid_from: DateTime<Utc>, valid_until: DateTime<Utc>, ) -> Result<Mandate, AppError>
Issue a new mandate. Caller MUST have already authorised the request (syndic / superadmin role check happens at the handler level).
Verify a user holds a currently-valid mandate of kind over scope.
Errors are precisely typed so the handler can surface the right kind
in the 403 response:
MandateExpired— pastvalid_until.MandateRevoked—revoked_at IS NOT NULL.MandateInvalidScope— no mandate matches the requested scope (e.g. notaire mandated on Building A, action on Building B).MandateNotFound— the subject has no mandate of this kind at all.
Sourcepub async fn revoke(&self, id: Uuid) -> Result<(), AppError>
pub async fn revoke(&self, id: Uuid) -> Result<(), AppError>
Annule un mandat avant son terme. Idempotent — un second appel ne
surcharge pas revoked_at.
pub async fn get(&self, id: Uuid) -> Result<Mandate, AppError>
pub async fn list_active_for_subject( &self, subject_user_id: Uuid, ) -> Result<Vec<Mandate>, AppError>
pub async fn list_for_scope( &self, scope: &MandateScope, ) -> Result<Vec<Mandate>, AppError>
Auto Trait Implementations§
impl !RefUnwindSafe for MandateUseCases
impl !UnwindSafe for MandateUseCases
impl Freeze for MandateUseCases
impl Send for MandateUseCases
impl Sync for MandateUseCases
impl Unpin for MandateUseCases
impl UnsafeUnpin for MandateUseCases
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.