Struct openmensa_rs::request::DayRequest[][src]

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

Struct to create and then issue requests to see a range of opening days.

Example

use openmensa_rs::request::DayRequest;

// As an example we just use the canteen with id `1` here
let req = DayRequest::new(1);
let list_of_days = req.build().await.unwrap();
println!("{:?}", list_of_days);

Implementations

impl DayRequest[src]

pub fn new(canteen_id: u16) -> Self[src]

Create a new instance to get opening days from a specific canteen. If you want to issue multiple requests, this struct implements Clone so before you issue a request simply .clone() if you need it later on.

pub fn with_start_date(self, start_date: Date<Utc>) -> Self[src]

Specfiy a start date from which opening days should be returned from. By default this is the current date, but you may specify another if you want e.g. to know the dates in a week or two.

pub async fn build(self) -> Result<Vec<Day>, 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.

Example

use openmensa_rs::request::DayRequest;

let canteen_id = 1;
let open_days = DayRequest::new(canteen_id)
    .with_start_date(
        chrono::Utc::today()
    )
    .build()
    .await
    .unwrap();

Trait Implementations

impl Clone for DayRequest[src]

fn clone(&self) -> DayRequest[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 Serialize for DayRequest[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.