Trait svc_storage::grpc::GrpcSimpleService
source · pub trait GrpcSimpleServicewhere
Self::ResourceObject: ObjectType<Self::Data> + PsqlType + PsqlSearch + SimpleResource<Self::Data> + PsqlObjectType<Self::Data> + From<Id> + From<Self::Data> + From<Self::UpdateObject> + Clone + Sync + Send,
Self::Data: GrpcDataObjectType + TryFrom<Row>,
Self::List: TryFrom<Vec<Row>>,
Self::Object: From<Self::ResourceObject>,
Self::UpdateObject: Send,
Self::Response: From<GenericResourceResult<Self::ResourceObject, Self::Data>>,
Status: From<<Self::Data as TryFrom<Row>>::Error> + From<<Self::List as TryFrom<Vec<Row>>>::Error>,{
type ResourceObject;
type Data;
type Object;
type UpdateObject;
type List;
type Response;
// Provided methods
fn generic_get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Object>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn generic_search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::List>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn generic_insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::Data>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn generic_update<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::UpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn generic_delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn generic_is_ready<'life0, 'async_trait>(
&'life0 self,
_request: Request<ReadyRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ReadyResponse>, Status>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Generic gRPC object traits to provide wrappers for common Resource
functions
Required Associated Types§
sourcetype ResourceObject
type ResourceObject
The type expected for the Self::ResourceObject<Self::Data>
type. Must implement;
ObjectType<Self::Data>
, PsqlType
, PsqlSearch
,
SimpleResource<Self::Data>
, PsqlObjectType<Self::Data>
, From<[Id]>
, From<[Self::Data]>
,
From<[Self::UpdateObject]>
, Clone
, Sync
, Send
sourcetype Data
type Data
The type expected for Data
structs. Must implement; GrpcDataObjectType
, TryFrom<[Row]>
sourcetype UpdateObject
type UpdateObject
The type expected for UpdateObject
structs. Must implement; Send
Provided Methods§
sourcefn generic_get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Object>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Object>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Returns a tonic
gRCP Response
containing an object of provided type Self::Object
.
Self::Object
will contain the record data found for the provided Id
.
Errors
Returns Status
with Code::NotFound
if no record is returned from the database.
Returns Status
with Code::Internal
if the provided Id can not be converted to a uuid::Uuid
.
Returns Status
with Code::Internal
if the resulting [Row
] data could not be converted into Self::Object
.
sourcefn generic_search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::List>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::List>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Returns a tonic
gRCP Response
containing an object of provided type Self::Object
.
Self::Object
(TryFrom<Vec<Row>>) will contain all records found in the database using the the provided AdvancedSearchFilter
.
This method supports paged results.
Errors
Returns Status
with Code::Internal
if any error is returned from the db search result.
Returns Status
with Code::Internal
if the resulting Vec<Row>
data could not be converted into Self::Object
.
sourcefn generic_insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::Data>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::Data>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Returns a tonic
gRCP Response
containing an object of provided type Self::Object
.
Self::Response
(From<GenericResourceResult<Self::ResourceObject, Self::Data>>) will contain the inserted record after saving the provided data Self::Data
.
The given data will be validated before insert.
A new UUID will be generated by the database and returned as id
as part of the returned Self::Response
.
Any errors found during validation will be added to the ValidationResult
.
Errors
Returns Status
with Code::Internal
if the Request
doesn’t contain any data.
Returns Status
with Code::Internal
if any error is returned from a db call.
sourcefn generic_update<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::UpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_update<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::UpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::Response>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Returns a tonic
gRCP Response
containing an object of provided type Self::Object
.
Self::Response
(From<GenericResourceResult<Self::ResourceObject, Self::Data>>) will contain the updated record after saving the provided data Self::Data
.
The given data will be validated before insert.
Any errors found during validation will be added to the ValidationResult
.
A field prost_types::FieldMask
can be provided to restrict updates to specific fields.
Errors
Returns Status
with Code::Cancelled
if the Request
doesn’t contain any data.
Returns Status
with Code::Internal
if any error is returned from a db call.
Returns Status
with Code::Internal
if the provided Id can not be converted to a uuid::Uuid
.
Returns Status
with Code::Internal
if the resulting [Row
] data could not be converted into Self::Data
.
sourcefn generic_delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Takes an Id
to set the matching database record as deleted in the database.
Errors
Returns Status
with Code::NotFound
if no record is returned from the database.
Returns Status
with Code::Internal
if any error is returned from a db call.
sourcefn generic_is_ready<'life0, 'async_trait>(
&'life0 self,
_request: Request<ReadyRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ReadyResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_is_ready<'life0, 'async_trait>(
&'life0 self,
_request: Request<ReadyRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ReadyResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Returns ready:true when service is available