exo_api/types.rs
1// Copyright 2026 Exochain Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at:
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17//! Shared API types — re-exports and API-specific additions.
18pub use exo_core::{Did, Hash256, Signature, Timestamp};
19use serde::{Deserialize, Serialize};
20
21/// An API version identifier.
22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
23pub struct ApiVersion(pub String);
24
25impl Default for ApiVersion {
26 fn default() -> Self {
27 Self("v1".into())
28 }
29}
30
31/// Pagination cursor for list endpoints.
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33pub struct Cursor(pub String);
34
35#[cfg(test)]
36#[allow(clippy::unwrap_used)]
37mod tests {
38 use super::*;
39 #[test]
40 fn api_version_default() {
41 assert_eq!(ApiVersion::default().0, "v1");
42 }
43 #[test]
44 fn cursor_serde() {
45 let c = Cursor("abc".into());
46 let j = serde_json::to_string(&c).unwrap();
47 let r: Cursor = serde_json::from_str(&j).unwrap();
48 assert_eq!(r, c);
49 }
50}