-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract client and server common entity
- Loading branch information
Showing
14 changed files
with
176 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
members = [ | ||
"server", | ||
"client", | ||
"tests" | ||
"tests", | ||
"entity", | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "entity" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_repr = "0.1" | ||
serde_json = "1" | ||
duration-str = "0.11" | ||
chrono = { version = "0.4", features = ["serde"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod request; | ||
pub mod storage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use crate::storage::UploadingStatus; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct GetDomainOption { | ||
pub domain: Option<String>, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug, Eq, PartialEq, Default)] | ||
pub enum GetDomainPositionFormat { | ||
#[default] | ||
Path, | ||
Json, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct GetDomainPositionOption { | ||
pub domain: String, | ||
//#[serde(default="crate::admin_server::request::GetDomainPositionFormat::Path")] | ||
#[serde(default)] | ||
pub format: GetDomainPositionFormat, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct UploadFileOption { | ||
pub domain: String, | ||
pub version: u32, | ||
pub path: String, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct DomainWithVersionOption { | ||
pub domain: String, | ||
pub version: u32, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct DomainWithOptVersionOption { | ||
pub domain: String, | ||
pub version: Option<u32>, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct UpdateUploadingStatusOption { | ||
pub domain: String, | ||
pub version: u32, | ||
pub status: UploadingStatus, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct DeleteDomainVersionOption { | ||
pub domain: Option<String>, | ||
pub max_reserve: Option<u32>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::path::PathBuf; | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_repr::{Deserialize_repr, Serialize_repr}; | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct DomainInfo { | ||
pub domain: String, // www.example.com|www.example.com/a/b | ||
pub current_version: Option<u32>, | ||
pub versions: Vec<u32>, | ||
//pub uploading_version: Vec<u32>, //TODO: add uploading_versions | ||
//pub web_path: Vec<String>, // [www.example.com/index.html|www.example.com/a/b/index.html,...] | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct ShortMetaData { | ||
pub path: String, | ||
pub md5: String, | ||
pub length: u64, | ||
} | ||
|
||
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] | ||
#[repr(u8)] | ||
pub enum UploadingStatus { | ||
Uploading = 0, | ||
Finish = 1, | ||
} | ||
|
||
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] | ||
#[repr(u8)] | ||
pub enum GetDomainPositionStatus { | ||
NewDomain = 0, | ||
NewVersion = 1, | ||
InUploading = 2, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct UploadDomainPosition { | ||
pub path: PathBuf, | ||
pub version: u32, | ||
pub status: GetDomainPositionStatus, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
pub struct CertInfo { | ||
pub begin: DateTime<Utc>, | ||
pub end: DateTime<Utc>, | ||
pub host: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.