Summary: The limitation to two types is arbitrary and limiting. Instead, we want to be able to create as many cache artifacts as is sensible to improve the caching behaviour. A lot of unnecessary cloning in here. I might optimise this a bit in the future but it's not really perf critical as this is highly I/O bound. Reviewed By: lblasa Differential Revision: D38155922 fbshipit-source-id: 78b86ebff54269c5049e59197f1c25fedfad0111
77 lines
1.5 KiB
Rust
77 lines
1.5 KiB
Rust
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
use std::fmt;
|
|
use std::fmt::Display;
|
|
use std::str;
|
|
|
|
#[derive(Eq, PartialEq, Debug, PartialOrd, Ord, Clone, serde::Deserialize)]
|
|
pub struct Platform(pub String);
|
|
|
|
impl str::FromStr for Platform {
|
|
type Err = &'static str;
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
Ok(Self(s.to_string()))
|
|
}
|
|
}
|
|
|
|
impl Display for Platform {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
#[derive(
|
|
Debug,
|
|
Clone,
|
|
PartialEq,
|
|
Eq,
|
|
PartialOrd,
|
|
Ord,
|
|
serde::Deserialize,
|
|
serde::Serialize
|
|
)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub struct PackType(String);
|
|
|
|
#[cfg(test)]
|
|
impl PackType {
|
|
pub fn new(s: &str) -> Self {
|
|
Self(s.to_string())
|
|
}
|
|
}
|
|
|
|
#[derive(
|
|
Debug,
|
|
Clone,
|
|
Copy,
|
|
PartialEq,
|
|
Eq,
|
|
PartialOrd,
|
|
Ord,
|
|
serde::Deserialize,
|
|
serde::Serialize
|
|
)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum PackMode {
|
|
/// All paths need to be specified.
|
|
Exact,
|
|
/// Can use `*` and `!` syntax to specify patterns for inclusion and exclusion.
|
|
/// Only works on the root folder level.
|
|
Glob,
|
|
}
|
|
|
|
impl Display for PackType {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
#[derive(Eq, PartialEq, Debug, serde::Serialize)]
|
|
pub struct HashSum(pub String);
|