cts-common 0.34.1-alpha.3

Common types and traits used across the CipherStash ecosystem
Documentation
use crate::{Crn, WorkspaceId};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct CreateWorkspaceResponse {
    pub id: WorkspaceId,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UpdateWorkspaceResponse {
    pub id: WorkspaceId,
    pub name: Option<String>,
    pub org_id: String,
    pub region: String,
    pub crn: Crn,
}

#[cfg(feature = "server")]
pub(super) mod server {
    use super::*;
    use axum::{response::IntoResponse, Json};

    impl IntoResponse for CreateWorkspaceResponse {
        fn into_response(self) -> axum::response::Response {
            (http::StatusCode::CREATED, Json(self)).into_response()
        }
    }

    impl IntoResponse for UpdateWorkspaceResponse {
        fn into_response(self) -> axum::response::Response {
            (http::StatusCode::OK, Json(self)).into_response()
        }
    }
}