pub struct CommitmentService { /* private fields */ }Expand description
Service for managing commitments
Implementations§
Source§impl CommitmentService
impl CommitmentService
pub fn new(pool: PgPool) -> Self
Sourcepub async fn create(
&self,
user_id: Uuid,
request: &CreateCommitmentRequest,
) -> Result<OutputCommitment>
pub async fn create( &self, user_id: Uuid, request: &CreateCommitmentRequest, ) -> Result<OutputCommitment>
Create a new commitment
Sourcepub async fn submit_evidence(
&self,
commitment_id: Uuid,
user_id: Uuid,
request: &SubmitEvidenceRequest,
) -> Result<OutputCommitment>
pub async fn submit_evidence( &self, commitment_id: Uuid, user_id: Uuid, request: &SubmitEvidenceRequest, ) -> Result<OutputCommitment>
Submit evidence for a commitment
Sourcepub async fn verify(
&self,
commitment_id: Uuid,
admin_id: Uuid,
request: &VerifyCommitmentRequest,
) -> Result<(OutputCommitment, Decimal)>
pub async fn verify( &self, commitment_id: Uuid, admin_id: Uuid, request: &VerifyCommitmentRequest, ) -> Result<(OutputCommitment, Decimal)>
Verify a commitment (admin only)
Sourcepub async fn get_user_commitments(
&self,
user_id: Uuid,
) -> Result<Vec<OutputCommitment>>
pub async fn get_user_commitments( &self, user_id: Uuid, ) -> Result<Vec<OutputCommitment>>
Get user’s commitments
Sourcepub async fn get_token_commitments(
&self,
token_id: Uuid,
) -> Result<Vec<OutputCommitment>>
pub async fn get_token_commitments( &self, token_id: Uuid, ) -> Result<Vec<OutputCommitment>>
Get token’s commitments
Sourcepub async fn get_pending_verification(
&self,
limit: i64,
) -> Result<Vec<OutputCommitment>>
pub async fn get_pending_verification( &self, limit: i64, ) -> Result<Vec<OutputCommitment>>
Get pending commitments for admin verification
Sourcepub async fn expire_overdue(&self) -> Result<u64>
pub async fn expire_overdue(&self) -> Result<u64>
Expire overdue commitments
Auto Trait Implementations§
impl Freeze for CommitmentService
impl !RefUnwindSafe for CommitmentService
impl Send for CommitmentService
impl Sync for CommitmentService
impl Unpin for CommitmentService
impl !UnwindSafe for CommitmentService
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> 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 more