hugging_face_client/api/
modify_collection_item.rs

1use serde::{Deserialize, Serialize};
2
3use crate::collection::CollectionItem;
4
5/// Request of [`crate::client::Client::modify_collection_item`]
6#[derive(Debug, Serialize)]
7pub struct ModifyCollectionItemReq<'a> {
8  #[serde(skip_serializing)]
9  pub(crate) collection_slug: &'a str,
10
11  #[serde(skip_serializing)]
12  pub(crate) item_id: &'a str,
13
14  #[serde(skip_serializing_if = "Option::is_none")]
15  pub(crate) position: Option<usize>,
16
17  #[serde(skip_serializing_if = "Option::is_none")]
18  pub(crate) note: Option<&'a str>,
19}
20
21impl<'a> ModifyCollectionItemReq<'a> {
22  pub fn new(collection_slug: &'a str, item_id: &'a str) -> Self {
23    Self {
24      collection_slug,
25      item_id,
26      position: None,
27      note: None,
28    }
29  }
30
31  pub fn position(mut self, position: usize) -> Self {
32    self.position = Some(position);
33    self
34  }
35
36  pub fn note(mut self, note: &'a str) -> Self {
37    self.note = Some(note);
38    self
39  }
40}
41
42/// Response of [`crate::client::Client::modify_collection_item`]
43#[derive(Debug, Deserialize)]
44pub struct ModifyCollectionItemRes {
45  pub success: bool,
46  pub data: CollectionItem,
47}