pub struct CreateUseCase<E, DTO, S> { /* private fields */ }Expand description
Generic “create entity” use case.
Lifecycle: hooks.before_create(dto) → factory.build(dto) →
hooks.after_build(entity) → service.persist(entity) →
hooks.after_create(entity)
Implementations§
Source§impl<E, DTO, S> CreateUseCase<E, DTO, S>
impl<E, DTO, S> CreateUseCase<E, DTO, S>
pub fn new( service: Arc<S>, factory: Arc<dyn EntityFactory<E, DTO>>, hooks: Arc<dyn UseCaseHooks<E, DTO>>, ) -> Self
pub fn with_default_hooks(
service: Arc<S>,
factory: Arc<dyn EntityFactory<E, DTO>>,
) -> Selfwhere
DTO: 'static,
pub async fn execute(&self, dto: DTO) -> UseCaseResult<E>
Auto Trait Implementations§
impl<E, DTO, S> !RefUnwindSafe for CreateUseCase<E, DTO, S>
impl<E, DTO, S> !UnwindSafe for CreateUseCase<E, DTO, S>
impl<E, DTO, S> Freeze for CreateUseCase<E, DTO, S>where
Arc<S>: Freeze,
Arc<dyn EntityFactory<E, DTO>>: Freeze,
Arc<dyn UseCaseHooks<E, DTO>>: Freeze,
PhantomData<(E, DTO)>: Freeze,
impl<E, DTO, S> Send for CreateUseCase<E, DTO, S>where
Arc<S>: Send,
Arc<dyn EntityFactory<E, DTO>>: Send,
Arc<dyn UseCaseHooks<E, DTO>>: Send,
PhantomData<(E, DTO)>: Send,
impl<E, DTO, S> Sync for CreateUseCase<E, DTO, S>where
Arc<S>: Sync,
Arc<dyn EntityFactory<E, DTO>>: Sync,
Arc<dyn UseCaseHooks<E, DTO>>: Sync,
PhantomData<(E, DTO)>: Sync,
impl<E, DTO, S> Unpin for CreateUseCase<E, DTO, S>where
Arc<S>: Unpin,
Arc<dyn EntityFactory<E, DTO>>: Unpin,
Arc<dyn UseCaseHooks<E, DTO>>: Unpin,
PhantomData<(E, DTO)>: Unpin,
impl<E, DTO, S> UnsafeUnpin for CreateUseCase<E, DTO, S>where
Arc<S>: UnsafeUnpin,
Arc<dyn EntityFactory<E, DTO>>: UnsafeUnpin,
Arc<dyn UseCaseHooks<E, DTO>>: UnsafeUnpin,
PhantomData<(E, DTO)>: UnsafeUnpin,
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
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