use crate::_auxlib as aux;
#[allow(non_snake_case)]
pub fn has_ingest_capacity<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> bool {
_ = T;
S > Uint::zero()
}
#[allow(non_snake_case)]
pub fn _assign_storage_site<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> Uint {
debug_assert!(has_ingest_capacity(S, T));
std::cmp::min(T, S)
}
#[allow(non_snake_case)]
pub fn assign_storage_site<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> Option<Uint> {
let k = _assign_storage_site(S, T);
if k == S {
None
} else {
Some(k)
}
}
pub struct Algo;
#[allow(non_snake_case)]
impl crate::dstream::HasIngestCapacityTrait for Algo {
fn has_ingest_capacity<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> bool {
has_ingest_capacity::<Uint>(S, T)
}
}
#[allow(non_snake_case)]
impl crate::dstream::AssignStorageSiteTrait for Algo {
fn _assign_storage_site<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> Uint {
_assign_storage_site::<Uint>(S, T)
}
fn assign_storage_site<Uint: aux::UnsignedTrait>(S: Uint, T: Uint) -> Option<Uint> {
assign_storage_site::<Uint>(S, T)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_smoke_has_ingest_capacity() {
has_ingest_capacity::<u32>(16, 101);
}
#[test]
fn test_smoke_impl_assign_storage_site() {
_assign_storage_site::<u32>(16, 101);
}
#[test]
fn test_smoke_assign_storage_site() {
assign_storage_site::<u32>(16, 101);
}
}