1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::future::IntoFuture;

use crate::{model::ServerOnlineCount, request::Request, routing::Route, ClientError, OrdrClient};

use super::OrdrFuture;

/// Get [`ServerOnlineCount`].
#[must_use]
pub struct GetServerOnlineCount<'a> {
    ordr: &'a OrdrClient,
}

impl<'a> GetServerOnlineCount<'a> {
    pub(crate) const fn new(ordr: &'a OrdrClient) -> Self {
        Self { ordr }
    }
}

impl IntoFuture for &mut GetServerOnlineCount<'_> {
    type Output = Result<ServerOnlineCount, ClientError>;
    type IntoFuture = OrdrFuture<ServerOnlineCount>;

    fn into_future(self) -> Self::IntoFuture {
        self.ordr
            .request(Request::from_route(Route::ServerOnlineCount))
    }
}

impl IntoFuture for GetServerOnlineCount<'_> {
    type Output = Result<ServerOnlineCount, ClientError>;
    type IntoFuture = OrdrFuture<ServerOnlineCount>;

    fn into_future(mut self) -> Self::IntoFuture {
        (&mut self).into_future()
    }
}