pub trait GrpcSimpleService
where 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§

source

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

source

type Data

The type expected for Data structs. Must implement; GrpcDataObjectType, TryFrom<[Row]>

source

type Object

The type expected for Object structs. Must implement; From<[Self::ResourceObject]>

source

type UpdateObject

The type expected for UpdateObject structs. Must implement; Send

source

type List

The type expected for List structs. Must implement TryFrom<[Vec<Row>]>

source

type Response

The type expected for Response structs. Must implement; From<[GenericResourceResult<Self::ResourceObject, Self::Data>]>

Provided Methods§

source

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.

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.

source

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.

source

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.

source

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.

source

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl GrpcSimpleService for svc_storage::grpc::server::adsb::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::flight_plan::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::group::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::itinerary::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::parcel::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::parcel_scan::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::pilot::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::scanner::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::user::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::vehicle::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::vertipad::GrpcServer

source§

impl GrpcSimpleService for svc_storage::grpc::server::vertiport::GrpcServer