Struct svc_storage::grpc::server::itinerary::GrpcServer
source · pub struct GrpcServer {}
Expand description
itinerarymodule including mock file Implementation of gRPC endpoints
Implementations§
Trait Implementations§
source§impl Clone for GrpcServer
impl Clone for GrpcServer
source§fn clone(&self) -> GrpcServer
fn clone(&self) -> GrpcServer
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GrpcServer
impl Debug for GrpcServer
source§impl Default for GrpcServer
impl Default for GrpcServer
source§fn default() -> GrpcServer
fn default() -> GrpcServer
source§impl GrpcSimpleService for GrpcServer
impl GrpcSimpleService for GrpcServer
§type ResourceObject = ResourceObject<Data>
type ResourceObject = ResourceObject<Data>
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
§type Object = Object
type Object = Object
Object
structs. Must implement; From<[Self::ResourceObject]>
§type UpdateObject = UpdateObject
type UpdateObject = UpdateObject
UpdateObject
structs. Must implement; Send
§type Response = Response
type Response = Response
Response
structs. Must implement; From<[GenericResourceResult<Self::ResourceObject, Self::Data>]>
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,
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,
tonic
gRCP Response
containing an object of provided type Self::Object
.
Self::Object
will contain the record data found for the provided Id
. Read moresource§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_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,
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
. Read moresource§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_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,
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
. Read moresource§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_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,
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
. Read moresource§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_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,
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,
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,
source§impl RpcService for GrpcServer
impl RpcService for GrpcServer
source§fn get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Object>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Object>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a tonic
gRCP Response
containing an itinerary Object
Errors
Returns tonic::Status
with tonic::Code::NotFound
if no record is returned from the database
Examples
use svc_storage::resources::Id;
use svc_storage::resources::itinerary::{Object, GrpcServer, RpcService};
async fn example() -> Result<Object, tonic::Status> {
let server = GrpcServer::default();
let id = "53acfe06-dd9b-42e8-8cb4-12a2fb2fa693".to_string();
let result = match server.get_by_id(tonic::Request::new(Id { id })).await
{
Ok(res) => res.into_inner(),
Err(e) => {
return Err(e);
},
};
log::debug!("{:?}", result);
Ok(result)
}
source§fn search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<List>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<List>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes an AdvancedSearchFilter
object to search the database with the provided values.
This method supports paged results.
Examples
use svc_storage::resources::{AdvancedSearchFilter, FilterOption, PredicateOperator, Id};
use svc_storage::resources::itinerary::{Object, List, GrpcServer, RpcService};
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
// Empty filter, but return paged results
let mut filters = vec![];
let advanced_filter = AdvancedSearchFilter {
filters,
page_number: 1,
results_per_page: 10,
order_by: vec![],
};
let result = match server.search(tonic::Request::new(advanced_filter)).await
{
Ok(res) => res.into_inner().list,
Err(e) => {
return Err(e);
},
};
log::debug!("{:?}", result);
Ok(())
}
source§fn insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Data>
) -> Pin<Box<dyn Future<Output = Result<Response<Response>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Data>
) -> Pin<Box<dyn Future<Output = Result<Response<Response>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes a itinerary Data
object to create a new itinerary with the provided data.
A new Uuid
will be generated by the database and returned as id
as part of the returned Object
.
Examples
use svc_storage::resources::Id;
use svc_storage::resources::itinerary::{Data, Response, GrpcServer, RpcService};
use svc_storage::resources::itinerary::mock;
const CAL_WORKDAYS_7AM_6PM: &str = "\
DTSTART:20221019T180000Z;DURATION:PT14H
RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
DTSTART:20221021T000000Z;DURATION:PT24H
RRULE:FREQ=WEEKLY;BYDAY=SA,SU";
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
let result = match server.insert(tonic::Request::new(mock::get_data_obj())).await
{
Ok(res) => res.into_inner(),
Err(e) => {
return Err(e);
},
};
log::debug!("{:?}", result);
Ok(())
}
source§fn update<'life0, 'async_trait>(
&'life0 self,
request: Request<UpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Response>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update<'life0, 'async_trait>(
&'life0 self,
request: Request<UpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Response>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes a itinerary UpdateObject
to update the resource with new data in the database
A field mask can be provided to restrict updates to specific fields.
Returns the updated Response
on success.
Examples
use svc_storage::resources::Id;
use svc_storage::resources::itinerary::{UpdateObject, Response, GrpcServer, RpcService};
use svc_storage::resources::itinerary::mock;
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
let result = match server.update(tonic::Request::new(UpdateObject {
id: "54acfe06-dd9b-42e8-8cb4-12a2fb2fa693".to_string(),
data: Some(mock::get_data_obj()),
mask: None
})).await
{
Ok(res) => res.into_inner(),
Err(e) => {
return Err(e);
},
};
log::debug!("{:?}", result);
Ok(())
}
source§fn delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes an Id
to set the matching itinerary record as deleted in the database.
Examples
use svc_storage::resources::Id;
use svc_storage::resources::itinerary::{GrpcServer, RpcService};
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
let id = "53acfe06-dd9b-42e8-8cb4-12a2fb2fa693".to_string();
let result = match server.delete(tonic::Request::new(Id { id })).await
{
Ok(res) => res.into_inner(),
Err(e) => {
return Err(e);
},
};
log::debug!("{:?}", result);
Ok(())
}
impl Copy for GrpcServer
Auto Trait Implementations§
impl RefUnwindSafe for GrpcServer
impl Send for GrpcServer
impl Sync for GrpcServer
impl Unpin for GrpcServer
impl UnwindSafe for GrpcServer
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
§impl<T> CloneAny for T
impl<T> CloneAny for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request