feature/github-email
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use chrono::{DateTime, Utc}; |
| 2 | use serde::{Deserialize, Serialize}; |
| 3 | use spinners::Spinner; |
| 4 | |
| 5 | mod ar_date_format { |
| 6 | use chrono::{DateTime, TimeZone, Utc}; |
| 7 | use serde::{self, Deserialize, Deserializer, Serializer}; |
| 8 | |
| 9 | const FORMAT: &'static str = "%Y-%m-%dT%H:%M:%S%.f%#z"; |
| 10 | |
| 11 | // The signature of a serialize_with function must follow the pattern: |
| 12 | // |
| 13 | // fn serialize<S>(&T, S) -> Result<S::Ok, S::Error> |
| 14 | // where |
| 15 | // S: Serializer |
| 16 | // |
| 17 | // although it may also be generic over the input types T. |
| 18 | pub fn serialize<S>(date: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error> |
| 19 | where |
| 20 | S: Serializer, |
| 21 | { |
| 22 | let s = format!("{}", date.naive_utc()); |
| 23 | serializer.serialize_str(&s) |
| 24 | } |
| 25 | |
| 26 | // The signature of a deserialize_with function must follow the pattern: |
| 27 | // |
| 28 | // fn deserialize<'de, D>(D) -> Result<T, D::Error> |
| 29 | // where |
| 30 | // D: Deserializer<'de> |
| 31 | // |
| 32 | // although it may also be generic over the output types T. |
| 33 | pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error> |
| 34 | where |
| 35 | D: Deserializer<'de>, |
| 36 | { |
| 37 | let s = String::deserialize(deserializer)?; |
| 38 | Utc.datetime_from_str(&s, FORMAT) |
| 39 | .map_err(serde::de::Error::custom) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | pub struct CommandResult { |
| 44 | pub spinner: Spinner, |
| 45 | pub symbol: String, |
| 46 | pub msg: String, |
| 47 | } |
| 48 | |
| 49 | #[derive(Serialize, Deserialize, Debug)] |
| 50 | pub struct AuthApp { |
| 51 | pub id: String, |
| 52 | pub secret: Option<String>, |
| 53 | pub name: String, |
| 54 | #[serde(with = "ar_date_format")] |
| 55 | pub created_at: DateTime<Utc>, |
| 56 | #[serde(with = "ar_date_format")] |
| 57 | pub updated_at: DateTime<Utc>, |
| 58 | } |
| 59 | |
| 60 | #[derive(Serialize, Deserialize, Debug)] |
| 61 | pub struct AuthAppCreate { |
| 62 | pub name: String, |
| 63 | pub description: String, |
| 64 | } |
| 65 | |
| 66 | #[derive(Deserialize, Debug, Serialize)] |
| 67 | pub struct Config { |
| 68 | pub current_project: Option<Project>, |
| 69 | pub current_auth_app: Option<AuthApp>, |
| 70 | } |
| 71 | |
| 72 | #[derive(Deserialize, Debug, Serialize)] |
| 73 | pub struct Project { |
| 74 | pub id: i32, |
| 75 | pub name: String, |
| 76 | #[serde(with = "ar_date_format")] |
| 77 | pub created_at: DateTime<Utc>, |
| 78 | #[serde(with = "ar_date_format")] |
| 79 | pub updated_at: DateTime<Utc>, |
| 80 | } |
| 81 | #[derive(Serialize, Debug)] |
| 82 | pub struct ProjectCreate { |
| 83 | pub name: String, |
| 84 | pub description: String, |
| 85 | } |