mz_frontegg_client/
parse.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use serde::{Deserialize, Deserializer};
11
12/// The pagination wrapper type for API calls that are paginated.
13#[derive(Debug, Clone, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct Paginated<T> {
16    pub items: Vec<T>,
17    #[serde(rename = "_metadata")]
18    pub metadata: PaginatedMetadata,
19}
20
21#[derive(Debug, Clone, Deserialize)]
22#[serde(rename_all = "camelCase")]
23pub struct PaginatedMetadata {
24    pub total_pages: u64,
25}
26
27/// A struct that deserializes nothing.
28///
29/// Useful for deserializing empty response bodies.
30pub struct Empty;
31
32impl<'de> Deserialize<'de> for Empty {
33    fn deserialize<D>(_: D) -> Result<Empty, D::Error>
34    where
35        D: Deserializer<'de>,
36    {
37        Ok(Empty)
38    }
39}