pub const DEFAULT_MAX_PAGE_SIZE: u32 = 100;
pub const DEFAULT_MAX_OFFSET: u32 = 1_000_000;
pub const DEFAULT_COLLECTION_LIMIT: usize = 1000;
pub const MAX_SESSIONS_PER_USER: usize = 100;
#[inline]
pub fn cap_limit(limit: u32) -> u32 {
limit.min(DEFAULT_MAX_PAGE_SIZE)
}
#[inline]
pub fn cap_offset(offset: u32) -> u32 {
offset.min(DEFAULT_MAX_OFFSET)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cap_limit() {
assert_eq!(cap_limit(50), 50);
assert_eq!(cap_limit(100), 100);
assert_eq!(cap_limit(200), DEFAULT_MAX_PAGE_SIZE);
}
#[test]
fn test_cap_offset() {
assert_eq!(cap_offset(500), 500);
assert_eq!(cap_offset(1_000_000), 1_000_000);
assert_eq!(cap_offset(2_000_000), DEFAULT_MAX_OFFSET);
}
}