Struct openmensa_rs::request::CanteenRequest[][src]

pub struct CanteenRequest { /* fields omitted */ }
Expand description

Struct to create a request receiving a list of canteens fitting the specified parameters.

This request does not require any additional information and can be stated as is to retrieve a list of all canteens.

Example

use openmensa_rs::request::CanteenRequest;
use openmensa_rs::CoordinatePair;

let near_canteens = CanteenRequest::new()
    .with_near_coordinates(
        CoordinatePair::new(
            52.1396188273019,
            11.6475999355316,
        )
    )
    .build()
    .await
    .unwrap();

Implementations

impl CanteenRequest[src]

pub fn new() -> Self[src]

Returns a new instance of a request. If you want to perform the same request again, you do not need to set all parameters anew. Requests are clonable, so to not lose them after building just create a clone!

use openmensa_rs::request::CanteenRequest;

let my_super_complex_request = CanteenRequest::new();
let result = my_super_complex_request.clone().build().await.unwrap();
// And we can use it again!
let result = my_super_complex_request.build().await.unwrap();

pub fn with_near_coordinates(self, near: CoordinatePair) -> Self[src]

Specify a CoordinatePair to which the canteen should be near to. If not further specified only canteens in a range of up to 10 kilometers will be returned. If you want to specify the range too, have a look at with_distance_to method.

pub fn with_distance_to(self, dst: f32, near: CoordinatePair) -> Self[src]

Specify a CoordinatePair and distance to which the canteen should be near too.

pub fn with_id<U: Into<u16>>(self, id: U) -> Self[src]

Add an id that should be included in the response.

Note: If at least one id is specified, only these ids will be included in the response. Even if other canteens would also match all other parameters. The same is true vice versa.

pub fn with_ids<T: Iterator>(self, ids: T) -> Self where
    T::Item: Into<u16>, 
[src]

Add multiple ids to the request.

pub fn with_coordinates_requisite(self) -> Self[src]

Return only canteens that have specified coordinates.

pub async fn build(self) -> Result<Vec<Canteen>, RequestError>[src]

Send the request and wait for the response. May return an error if the parameters cannot be serialized or the response cannot be deserialized.


let near_canteens = CanteenRequest::new()
    .with_near_coordinates(
        CoordinatePair::new(
            52.1396188273019,
            11.6475999355316,
        )
    )
    .build()
    .await
    .unwrap();

Trait Implementations

impl Clone for CanteenRequest[src]

fn clone(&self) -> CanteenRequest[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for CanteenRequest[src]

fn default() -> CanteenRequest[src]

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

impl Serialize for CanteenRequest[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.