pub struct GrpcServer {}
Expand description

flight_plan_parcelmodule including mock file Implementation of gRPC endpoints

Implementations§

source§

impl GrpcServer

source

pub fn get_name(&self) -> String

Get name string for service

Trait Implementations§

source§

impl Clone for GrpcServer

source§

fn clone(&self) -> GrpcServer

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GrpcServer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for GrpcServer

source§

fn default() -> GrpcServer

Returns the “default value” for a type. Read more
source§

impl GrpcSimpleServiceLinked for GrpcServer

§

type LinkedResourceObject = ResourceObject<Data>

The type expected for the 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

The type expected for the Data struct of the linked resource. Must implement; GrpcDataObjectType, TryFrom<[Row]>
§

type LinkedRowData = RowData

The type expected for the RowData struct of the linked resource. Must implement; TryFrom<[Row]>
§

type LinkedObject = Object

The type expected for the Object struct of the linked resource. Must implement; From<[Self::LinkedResourceObject]>
§

type LinkedUpdateObject = UpdateObject

The type expected for the UpdateObject struct of the linked resourceLinked. Must implement; Send
§

type LinkedList = List

The type expected for the List struct of the linked resource. Must implement; TryFrom<[Vec<Row>]>
§

type LinkedRowDataList = RowDataList

The type expected for the RowDataList struct of the linked resource. Must implement; TryFrom<[Vec<Row>]>
§

type LinkedResponse = Response

The type expected for the Response struct of the linked resource. Must implement; TryFrom<[Vec<Row>]>
§

type ResourceObject = ResourceObject<Data>

The type expected for the 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

The type expected for the Data struct of the ‘main’ resource. Must implement; GrpcDataObjectType, TryFrom<[Row]>
§

type OtherResourceObject = ResourceObject<Data>

The type expected for the 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

The type expected for the Data struct of the ‘other’ resource. Must implement; GrpcDataObjectType, TryFrom<[Row]>
§

type OtherList = List

The type expected for the List struct of the ‘other’ resource. Must implement; 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,

Returns a tonic gRCP Response containing an object of provided type Self::LinkedObject. Self::Object will contain the record data found for the provided Ids. Read more
Returns a 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 more
Returns an empty tonic gRCP Response on success Read more
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>>
where Self: Send + 'async_trait + Sync, 'life0: 'async_trait,

Returns a tonic gRCP Response with IdList of found ids on success Read more
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>>
where Self: Send + 'async_trait + Sync, 'life0: 'async_trait,

Returns a tonic gRCP Response containing an object of provided type Self::OtherList. Read more
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,

Internal function used for 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,

Returns a 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 more
source§

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,

Returns a 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 more
source§

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,

Takes an Id to set the matching database record as deleted in the database. Read more
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
source§

impl RpcServiceLinked for GrpcServer

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,

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,

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,

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,

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,

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,

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,

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(())
}
source§

fn is_ready<'life0, 'async_trait>( &'life0 self, request: Request<ReadyRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<ReadyResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns ready:true when service is available

source§

impl Copy for GrpcServer

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneAny for T
where T: Any + Clone + Send + Sync,

§

fn clone_any(&self) -> Box<dyn CloneAny>

§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>

§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>

§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> DebugAny for T
where T: Any + Debug,

§

impl<T> UnsafeAny for T
where T: Any,