#[derive(Debug, Clone, PartialEq)]
pub enum ScaleBinding {
ProblemSize,
DataVolume,
Throughput,
Custom(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ByteSize(pub usize);
impl ByteSize {
pub fn mb(mb: usize) -> Self {
ByteSize(mb * 1024 * 1024)
}
pub fn gb(gb: usize) -> Self {
ByteSize(gb * 1024 * 1024 * 1024)
}
pub fn bytes(&self) -> usize {
self.0
}
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ResourceMapping {
pub cores: Option<ScaleBinding>,
pub memory: Option<ScaleBinding>,
pub bandwidth: Option<ScaleBinding>,
pub latency: Option<ScaleBinding>,
pub cores_value: Option<usize>,
pub memory_value: Option<ByteSize>,
}
impl ResourceMapping {
pub fn new() -> Self {
Self::default()
}
pub fn cores(mut self, binding: ScaleBinding) -> Self {
self.cores = Some(binding);
self
}
pub fn cores_value(mut self, count: usize) -> Self {
self.cores_value = Some(count);
self
}
pub fn memory(mut self, binding: ScaleBinding) -> Self {
self.memory = Some(binding);
self
}
pub fn memory_value(mut self, size: ByteSize) -> Self {
self.memory_value = Some(size);
self
}
}