pub struct SearchableCrudServiceAdapter<R, E, C, U>where
R: SearchableRepository<E> + Send + Sync,
E: PersistentEntity,
C: Send + Sync,
U: Send + Sync,{ /* private fields */ }Expand description
Adapter for repositories that implement SearchableRepository
This adapter provides full filter support in the list method by leveraging
the SearchableRepository::search method.
§Example
ⓘ
use backbone_core::persistence::{InMemoryRepository, SearchableCrudServiceAdapter};
let repo = Arc::new(InMemoryRepository::<User>::new());
let service = SearchableCrudServiceAdapter::new(
repo,
"User",
|dto: CreateUserDto| User::from(dto),
|entity: &mut User, dto: UpdateUserDto| entity.apply_update(dto),
);Implementations§
Source§impl<R, E, C, U> SearchableCrudServiceAdapter<R, E, C, U>where
R: SearchableRepository<E> + Send + Sync,
E: PersistentEntity,
C: Send + Sync,
U: Send + Sync,
impl<R, E, C, U> SearchableCrudServiceAdapter<R, E, C, U>where
R: SearchableRepository<E> + Send + Sync,
E: PersistentEntity,
C: Send + Sync,
U: Send + Sync,
Trait Implementations§
Source§impl<R, E, C, U> CrudService<E, C, U> for SearchableCrudServiceAdapter<R, E, C, U>where
R: SearchableRepository<E> + Send + Sync + 'static,
E: PersistentEntity + Clone + 'static,
C: Send + Sync + 'static,
U: Send + Sync + 'static,
impl<R, E, C, U> CrudService<E, C, U> for SearchableCrudServiceAdapter<R, E, C, U>where
R: SearchableRepository<E> + Send + Sync + 'static,
E: PersistentEntity + Clone + 'static,
C: Send + Sync + 'static,
U: Send + Sync + 'static,
Source§type Error = AdapterError
type Error = AdapterError
Error type for service operations
Source§fn entity_name() -> &'static str
fn entity_name() -> &'static str
Entity name for error messages (e.g., “User”, “Role”)
Source§fn list<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List entities with pagination and filters Read more
Source§fn aggregate<'life0, 'life1, 'async_trait>(
&'life0 self,
spec: &'life1 AggregateSpec,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<AggregateResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn aggregate<'life0, 'life1, 'async_trait>(
&'life0 self,
spec: &'life1 AggregateSpec,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<AggregateResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Group and reduce the rows
list would return, under the same filters. Read moreSource§fn table_name(&self) -> Option<&str>
fn table_name(&self) -> Option<&str>
The schema-qualified table this service reads, when it has one. Read more
Source§fn create<'life0, 'async_trait>(
&'life0 self,
dto: C,
) -> Pin<Box<dyn Future<Output = Result<E, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
dto: C,
) -> Pin<Box<dyn Future<Output = Result<E, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new entity Read more
Source§fn get_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get entity by ID Read more
Source§fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
dto: U,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
dto: U,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Full update of entity Read more
Source§fn partial_update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
_fields: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn partial_update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
_fields: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Partial update with specific fields Read more
Source§fn soft_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn soft_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Soft delete entity Read more
Source§fn bulk_create<'life0, 'async_trait>(
&'life0 self,
items: Vec<C>,
) -> Pin<Box<dyn Future<Output = Result<Vec<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_create<'life0, 'async_trait>(
&'life0 self,
items: Vec<C>,
) -> Pin<Box<dyn Future<Output = Result<Vec<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Bulk create multiple entities Read more
Source§fn upsert<'life0, 'async_trait>(
&'life0 self,
dto: C,
) -> Pin<Box<dyn Future<Output = Result<E, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert<'life0, 'async_trait>(
&'life0 self,
dto: C,
) -> Pin<Box<dyn Future<Output = Result<E, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Upsert (create or update) Read more
Source§fn list_deleted<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_deleted<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List deleted entities (trash) Read more
Source§fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Restore soft-deleted entity Read more
Source§fn empty_trash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn empty_trash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Permanently delete all soft-deleted entities Read more
Source§fn get_deleted_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_deleted_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<E>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get deleted entity by ID (from trash) Read more
Source§fn permanent_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn permanent_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Permanently delete a single soft-deleted entity by ID Read more
Source§fn list_deleted_filtered<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_deleted_filtered<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<E>, u64), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List deleted entities with filters Read more
Source§fn count_active<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_active<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count active (non-deleted) entities Read more
Source§fn count_deleted<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_deleted<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count deleted entities in trash Read more
Source§fn violations_of(err: &Self::Error) -> Option<Vec<Violation>>
fn violations_of(err: &Self::Error) -> Option<Vec<Violation>>
The named rules a refused write broke, when the error carries them, so
the response can list them beside the sentence.
None by default.Hydrate
?include= relations: fetch rows from table by id list, as JSON.
Default: no expansion. GenericCrudService delegates to its repository.Source§fn list_with_info<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Entity>, PaginationInfo), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_with_info<'life0, 'async_trait>(
&'life0 self,
page: u32,
limit: u32,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Entity>, PaginationInfo), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
list, carrying the pagination info (cursor positions included) so
the HTTP layer can surface keyset paging. Default: the tuple form —
generated services override this with the repository’s cursors.Source§fn count_active_filtered<'life0, 'async_trait>(
&'life0 self,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_active_filtered<'life0, 'async_trait>(
&'life0 self,
filters: HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count active entities MATCHING the caller’s filters. Read more
Source§fn bulk_soft_delete<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_soft_delete<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Soft-delete many entities by id. Returns the number affected. Read more
Source§fn bulk_restore<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_restore<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Restore many soft-deleted entities by id. Returns the restored rows. Read more
Source§fn bulk_permanent_delete<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_permanent_delete<'life0, 'async_trait>(
&'life0 self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Permanently delete many soft-deleted entities by id. Read more
Source§fn restore_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn restore_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Restore every soft-deleted entity. Returns the number restored. Read more
Source§fn bulk_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, UpdateDto)>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, UpdateDto)>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Full-update many entities. Each item is
(id, UpdateDto). Read moreSource§fn bulk_partial_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, HashMap<String, Value>)>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bulk_partial_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, HashMap<String, Value>)>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Partial-update many entities. Each item is
(id, field_map). Read moreSource§fn preview_bulk_partial_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, HashMap<String, Value>)>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<BulkPreviewRow<Entity, Self::Error>>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn preview_bulk_partial_update<'life0, 'async_trait>(
&'life0 self,
items: Vec<(String, HashMap<String, Value>)>,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<BulkPreviewRow<Entity, Self::Error>>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
What
bulk_partial_update would do, with
nothing written: each row as it is and as it would become, or why the
write would refuse it. Ok(None) (the default) means this service has no
dry run, and the route says so instead of guessing. Read moreAuto Trait Implementations§
impl<R, E, C, U> !RefUnwindSafe for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> !UnwindSafe for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> Freeze for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> Send for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> Sync for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> Unpin for SearchableCrudServiceAdapter<R, E, C, U>
impl<R, E, C, U> UnsafeUnpin for SearchableCrudServiceAdapter<R, E, C, U>where
Arc<R>: UnsafeUnpin,
Box<dyn Fn(C) -> E + Sync + Send>: UnsafeUnpin,
Box<dyn Fn(&mut E, U) + Sync + Send>: 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