-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(api): Separate
Deploy
struct into separate submodule (#2161)
Also, use `Cow` in the struct to avoid allocations
- Loading branch information
1 parent
099919a
commit 19d08fb
Showing
4 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
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,29 @@ | ||
//! The `Deploy` data type. | ||
|
||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::borrow::Cow; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
pub struct Deploy<'d> { | ||
#[serde(rename = "environment")] | ||
pub env: Cow<'d, str>, | ||
pub name: Option<Cow<'d, str>>, | ||
pub url: Option<Cow<'d, str>>, | ||
#[serde(rename = "dateStarted")] | ||
pub started: Option<DateTime<Utc>>, | ||
#[serde(rename = "dateFinished")] | ||
pub finished: Option<DateTime<Utc>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub projects: Option<Vec<Cow<'d, str>>>, | ||
} | ||
|
||
impl<'d> Deploy<'d> { | ||
/// Returns the name of this deploy, defaulting to `"unnamed"`. | ||
pub fn name(&self) -> &str { | ||
match self.name.as_deref() { | ||
Some("") | None => "unnamed", | ||
Some(name) => name, | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
//! Data types used in the api module | ||
|
||
mod chunking; | ||
mod deploy; | ||
|
||
pub use self::chunking::*; | ||
pub use self::deploy::*; |
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