lichess_api/model/users/
by_id.rs1use crate::model::{Body, Request};
2use serde::Serialize;
3use std::borrow::Borrow;
4
5#[derive(Default, Clone, Debug, Serialize)]
6pub struct PostQuery;
7pub type PostRequest = Request<PostQuery, String>;
8
9impl PostRequest {
10 pub fn new<Ids: AsRef<[Id]>, Id: Borrow<str>>(ids: Ids) -> Self {
11 let ids = ids.as_ref().join(",");
12 Self::post("/api/users", None, Body::PlainText(ids), None)
13 }
14}
15
16impl<Id: Borrow<str>> From<&[Id]> for PostRequest {
17 fn from(ids: &[Id]) -> Self {
18 Self::new(ids)
19 }
20}
21
22impl<const N: usize, Id: Borrow<str>> From<&[Id; N]> for PostRequest {
23 fn from(ids: &[Id; N]) -> Self {
24 Self::new(ids)
25 }
26}
27
28impl<const N: usize, Id: Borrow<str>> From<[Id; N]> for PostRequest {
29 fn from(ids: [Id; N]) -> Self {
30 Self::new(ids)
31 }
32}
33
34impl<Id: Borrow<str>> From<&Vec<Id>> for PostRequest {
35 fn from(ids: &Vec<Id>) -> Self {
36 Self::new(ids)
37 }
38}
39
40impl<Id: Borrow<str>> From<Vec<Id>> for PostRequest {
41 fn from(ids: Vec<Id>) -> Self {
42 Self::new(ids)
43 }
44}