contentstack_api_client_rs/client/entries.rs
1use serde::Deserialize;
2
3/// A Contentstack entry with system fields plus caller-defined custom fields.
4///
5/// System fields (`uid`, `title`, `locale`, etc.) are always present.
6/// `T` holds your content type's custom fields, deserialized from the same
7/// JSON object via `#[serde(flatten)]`.
8///
9/// # Example
10///
11/// ```no_run
12/// use serde::Deserialize;
13/// use contentstack_api_client_rs::Entry;
14///
15/// #[derive(Deserialize)]
16/// struct BlogPost {
17/// pub body: String,
18/// pub url: String,
19/// }
20///
21/// // entry.uid, entry.title - system fields
22/// // entry.fields.body - your custom field
23/// ```
24#[derive(Debug, Deserialize)]
25pub struct Entry<T> {
26 pub uid: String,
27 pub title: String,
28 pub locale: String,
29 pub created_at: String,
30 pub updated_at: String,
31 pub created_by: String,
32 pub updated_by: String,
33 #[serde(rename = "_version")]
34 pub version: u32,
35 /// Caller's custom fields - flattened into the same JSON object.
36 #[serde(flatten)]
37 pub fields: T,
38}
39
40/// Response wrapper for a list of entries.
41///
42/// Contentstack returns `{ "entries": [...], "count": N }`.
43/// `count` is only present when `include_count: true` is set in params.
44#[derive(Debug, Deserialize)]
45pub struct EntriesResponse<T> {
46 pub entries: Vec<Entry<T>>,
47 pub count: Option<u32>,
48}
49
50/// Response wrapper for a single entry.
51///
52/// Contentstack returns `{ "entry": { ... } }`.
53#[derive(Debug, Deserialize)]
54pub struct EntryResponse<T> {
55 pub entry: Entry<T>,
56}