Struct svc_storage::grpc::server::flight_plan_parcel::GrpcServer
source · pub struct GrpcServer {}
Expand description
flight_plan_parcelmodule 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 GrpcSimpleServiceLinked for GrpcServer
impl GrpcSimpleServiceLinked for GrpcServer
§type LinkedResourceObject = ResourceObject<Data>
type LinkedResourceObject = ResourceObject<Data>
Self::ResourceObject<Self::Data>
type of the linked resource.
Must implement; ObjectType<Self::Data>
, PsqlType
, PsqlSearch
,
SimpleResourceLinked<Self::Data>
, PsqlObjectType<Self::Data>
, From<[Id]>
, From<[Self::Data]>
,
From<[Self::UpdateObject]>
, Clone
, Sync
, Send
§type LinkedData = Data
type LinkedData = Data
GrpcDataObjectType
, TryFrom<[Row]>
§type LinkedRowData = RowData
type LinkedRowData = RowData
TryFrom<[Row]>
§type LinkedObject = Object
type LinkedObject = Object
From<[Self::LinkedResourceObject]>
§type LinkedUpdateObject = UpdateObject
type LinkedUpdateObject = UpdateObject
Send
§type LinkedList = List
type LinkedList = List
TryFrom<[Vec<Row>]>
§type LinkedRowDataList = RowDataList
type LinkedRowDataList = RowDataList
TryFrom<[Vec<Row>]>
§type LinkedResponse = Response
type LinkedResponse = Response
TryFrom<[Vec<Row>]>
§type ResourceObject = ResourceObject<Data>
type ResourceObject = ResourceObject<Data>
Self::ResourceObject<Self::Data>
type of the ‘main’ resource.
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 Data = Data
type Data = Data
GrpcDataObjectType
, TryFrom<[Row]>
§type OtherResourceObject = ResourceObject<Data>
type OtherResourceObject = ResourceObject<Data>
Self::ResourceObject<Self::Data>
type of the ‘other’ resource.
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 OtherData = Data
type OtherData = Data
GrpcDataObjectType
, TryFrom<[Row]>
§type OtherList = List
type OtherList = List
TryFrom<Vec<Row>>
source§fn generic_get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Ids>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedObject>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Ids>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedObject>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
tonic
gRCP Response
containing an object of provided type Self::LinkedObject
.
Self::Object
will contain the record data found for the provided Ids
. Read moresource§fn generic_search<'life0, 'async_trait>(
&'life0 self,
request: Request<AdvancedSearchFilter>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedRowDataList>, 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::LinkedRowDataList>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
tonic
gRCP Response
containing an object of provided type Self::LinkedRowDataList
.
Self::Object
(TryFrom<Vec<Row>>) will contain all records found in the database using the the provided AdvancedSearchFilter
. Read moresource§fn generic_unlink<'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_unlink<'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_get_linked_ids<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<IdList>, Status>> + Send + 'async_trait>>
fn generic_get_linked_ids<'life0, 'async_trait>( &'life0 self, request: Request<Id> ) -> Pin<Box<dyn Future<Output = Result<Response<IdList>, Status>> + Send + 'async_trait>>
source§fn generic_get_linked<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::OtherList>, Status>> + Send + 'async_trait>>
fn generic_get_linked<'life0, 'async_trait>( &'life0 self, request: Request<Id> ) -> Pin<Box<dyn Future<Output = Result<Response<Self::OtherList>, Status>> + Send + 'async_trait>>
source§fn _get_linked<'async_trait>(
id: Id
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ArrErr>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
fn _get_linked<'async_trait>(
id: Id
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ArrErr>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
generic_get_linked_ids
and generic_get_linked
source§fn generic_insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::LinkedRowData>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_insert<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::LinkedRowData>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
tonic
gRCP Response
containing an object of provided type Self::LinkedResponse
.
Self::Response(From<GenericResourceResult<Self::LinkedResourceObject, Self::Data>>)
will contain the inserted record after saving the provided data Self::LinkedRowData
. Read moresource§fn generic_update<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::LinkedUpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn generic_update<'life0, 'async_trait>(
&'life0 self,
request: Request<Self::LinkedUpdateObject>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::LinkedResponse>, Status>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
tonic
gRCP Response
containing an object of provided type Self::LinkedResourceObject
.
Self::Response(From<GenericResourceResult<Self::LinkedResourceObject, Self::Data>>)
will contain the updated record after saving the provided data Self::LinkedUpdateObject
. Read moresource§fn generic_delete<'life0, 'async_trait>(
&'life0 self,
request: Request<Ids>
) -> 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<Ids>
) -> 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 RpcServiceLinked for GrpcServer
impl RpcServiceLinked for GrpcServer
source§fn unlink<'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 unlink<'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 unlink all parcel linked ids in the database.
Errors
Returns tonic::Status
with tonic::Code::NotFound
if the provided id
is not found in the database.
source§fn get_linked_ids<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<IdList>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_linked_ids<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<IdList>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes an Id
to get all parcel linked ids from the database.
Errors
Returns tonic::Status
with tonic::Code::NotFound
if the provided id
is not found in the database.
source§fn get_linked<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<List>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_linked<'life0, 'async_trait>(
&'life0 self,
request: Request<Id>
) -> Pin<Box<dyn Future<Output = Result<Response<List>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes an Id
to get all parcel linked objects from the database.
Errors
Returns tonic::Status
with tonic::Code::NotFound
if the provided id
is not found in the database.
source§fn get_by_id<'life0, 'async_trait>(
&'life0 self,
request: Request<Ids>
) -> 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<Ids>
) -> 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 flight_plan_parcel Object
Errors
Returns tonic::Status
with tonic::Code::NotFound
if no record is returned from the database
Examples
use svc_storage::resources::{Ids, FieldValue};
use svc_storage::resources::flight_plan_parcel::{Object, GrpcServer, RpcServiceLinked};
async fn example() -> Result<Object, tonic::Status> {
let server = GrpcServer::default();
let id1 = "53acfe06-dd9b-42e8-8cb4-12a2fb2fa693";
let id2 = "279f750f-712f-4c3b-8c92-331b79ffa7f9";
let result = match server.get_by_id(tonic::Request::new(Ids {
ids: vec![
FieldValue {
field: String::from("field_1"),
value: String::from(id1)
},
FieldValue {
field: String::from("field_2"),
value: String::from(id2)
},
]
})).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<RowDataList>, 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<RowDataList>, 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::flight_plan_parcel::{Object, List, GrpcServer, RpcServiceLinked};
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<RowData>
) -> 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<RowData>
) -> Pin<Box<dyn Future<Output = Result<Response<Response>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Takes a flight_plan_parcel Data
object to create a new flight_plan_parcel 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::flight_plan_parcel::{Data, Response, GrpcServer, RpcServiceLinked};
use svc_storage::resources::flight_plan_parcel::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_row_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 flight_plan_parcel 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::{FieldValue, Ids};
use svc_storage::resources::flight_plan_parcel::{UpdateObject, Response, GrpcServer, RpcServiceLinked};
use svc_storage::resources::flight_plan_parcel::mock;
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
let id1 = "53acfe06-dd9b-42e8-8cb4-12a2fb2fa693";
let id2 = "279f750f-712f-4c3b-8c92-331b79ffa7f9";
let result = match server.update(tonic::Request::new(UpdateObject {
ids: vec![
FieldValue {
field: String::from("field_1"),
value: String::from(id1)
},
FieldValue {
field: String::from("field_2"),
value: String::from(id2)
},
],
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<Ids>
) -> 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<Ids>
) -> 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 flight_plan_parcel record as deleted in the database.
Examples
use svc_storage::resources::{FieldValue, Ids};
use svc_storage::resources::flight_plan_parcel::{GrpcServer, RpcServiceLinked};
async fn example() -> Result<(), tonic::Status> {
let server = GrpcServer::default();
let id1 = "53acfe06-dd9b-42e8-8cb4-12a2fb2fa693";
let id2 = "279f750f-712f-4c3b-8c92-331b79ffa7f9";
let result = match server.delete(tonic::Request::new(Ids {
ids: vec![
FieldValue {
field: String::from("field_1"),
value: String::from(id1)
},
FieldValue {
field: String::from("field_2"),
value: String::from(id2)
},
]
})).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