aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_common/api.rs
blob: c18db04fb94834c397908c984c8ef3e35a0d2ec2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use semver::Version;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::sync::LazyLock;

// the usage of X- has been deprecated for quite along time, it turns out
pub(crate) static ATUIN_HEADER_VERSION: &str = "Atuin-Version";
pub(crate) static ATUIN_CARGO_VERSION: &str = env!("CARGO_PKG_VERSION");

pub(crate) static ATUIN_VERSION: LazyLock<Version> =
    LazyLock::new(|| Version::parse(ATUIN_CARGO_VERSION).expect("failed to parse self semver"));

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct RegisterResponse {
    pub(crate) session: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ChangePasswordRequest {
    pub(crate) current_password: String,
    pub(crate) new_password: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct LoginRequest {
    pub(crate) username: String,
    pub(crate) password: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct LoginResponse {
    pub(crate) session: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ErrorResponse<'a> {
    pub(crate) reason: Cow<'a, str>,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct IndexResponse {
    pub(crate) homage: String,
    pub(crate) version: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct MeResponse {
    pub(crate) username: String,
}