1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use lexoffice::request::RequestWithState;
use lexoffice::request::{ById, Endpoint};
use lexoffice::Result;
use serde::de::DeserializeOwned;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
pub struct ByIdOpt {
    /// uuid of the element
    id: String,
}

impl ByIdOpt {
    pub async fn exec<T, U>(&self, request: RequestWithState<T, U>) -> Result<T>
    where
        RequestWithState<T, U>: ById + Endpoint + Clone,
        T: DeserializeOwned + Clone,
        U: Clone,
    {
        request.by_id_str(&self.id).await
    }
}