hugging_face_client/api/
create_collection_item.rs1use serde::Serialize;
2
3use crate::{RepoType, collection::Collection};
4
5#[derive(Debug, Serialize)]
7pub struct CreateCollectionItemReq<'a> {
8 #[serde(skip_serializing)]
9 pub(crate) collection_slug: &'a str,
10
11 item: CreateCollectionItemInner<'a>,
12 pub(crate) note: Option<&'a str>,
13}
14
15#[derive(Debug, Serialize)]
16struct CreateCollectionItemInner<'a> {
17 #[serde(rename = "type")]
18 item_type: RepoType,
19
20 id: &'a str,
21}
22
23impl<'a> CreateCollectionItemReq<'a> {
24 pub fn new(collection_slug: &'a str, item_id: &'a str, item_type: RepoType) -> Self {
25 let item = CreateCollectionItemInner {
26 item_type,
27 id: item_id,
28 };
29 CreateCollectionItemReq {
30 collection_slug,
31 item,
32 note: None,
33 }
34 }
35
36 pub fn note(mut self, note: &'a str) -> Self {
37 self.note = Some(note);
38 self
39 }
40}
41
42pub type CreateCollectionItemRes = Collection;