Skip to content

Commit

Permalink
squash! fix(coapcore): overhault pub'ness
Browse files Browse the repository at this point in the history
Items in oluru remain pub in order to run their tests; the whole module
is only pub for testing anyway.
  • Loading branch information
chrysn committed Jan 31, 2025
1 parent 8db6533 commit d5c5160
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/coapcore/src/oluru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use arrayvec::ArrayVec;
/// Priority levels follow the conventions common with schedulers: 0 is the highest priority, and
/// will only get evicted if the cache is full with other entries of the same priority. Larger
/// numeric values indicate increasingly lower priority.
pub(crate) trait PriorityLevel {
pub trait PriorityLevel {
/// Calculate the priority of the instance
///
/// An instance's priority level may change while being mutated; [`OrderedPool`] will account for
Expand Down Expand Up @@ -111,7 +111,7 @@ pub(crate) trait PriorityLevel {
/// values is unique, and is an index into `.entries`.
/// * If `T::level` is constant, `self.sorted.iter().map(|i| self.entries[i].level())` is sorted.
#[derive(Debug)]
pub(crate) struct OrderedPool<T: PriorityLevel, const N: usize, const L: usize> {
pub struct OrderedPool<T: PriorityLevel, const N: usize, const L: usize> {
/// Elements without regard for ordering
pub entries: ArrayVec<T, N>,
/// A sorted list of indices into entries: high priority first, ties broken by recentness
Expand All @@ -120,7 +120,7 @@ pub(crate) struct OrderedPool<T: PriorityLevel, const N: usize, const L: usize>

impl<T: PriorityLevel, const N: usize, const L: usize> OrderedPool<T, N, L> {
/// Create an empty cache.
pub(crate) const fn new() -> Self {
pub const fn new() -> Self {
assert!(N < u16::MAX as usize, "Capacity overflow");
// Clipping levels to u16 because they may be stored if the implementation changes.
assert!(L < u16::MAX as usize, "Level overflow");
Expand All @@ -145,7 +145,7 @@ impl<T: PriorityLevel, const N: usize, const L: usize> OrderedPool<T, N, L> {
/// * The callback is split in a test part and a use part, which ensures that elements that are
/// not looked up do not get mutated; only the selected item is mutated and will then be
/// sorted in correctly.
pub(crate) fn lookup<Ftest, Fuse, R>(&mut self, mut f_test: Ftest, f_use: Fuse) -> Option<R>
pub fn lookup<Ftest, Fuse, R>(&mut self, mut f_test: Ftest, f_use: Fuse) -> Option<R>
where
Ftest: FnMut(&T) -> bool,
Fuse: FnOnce(&mut T) -> R,
Expand All @@ -170,7 +170,7 @@ impl<T: PriorityLevel, const N: usize, const L: usize> OrderedPool<T, N, L> {
dead_code,
reason = "Need for this function is unclear, but it is covered in tests and docs, and may easily be needed again as coapcore is being refactored."
)]
pub(crate) fn insert(&mut self, new: T) -> Result<Option<T>, T> {
pub fn insert(&mut self, new: T) -> Result<Option<T>, T> {
let new_index = self.entries.len();
if new_index < N {
self.entries.push(new);
Expand Down Expand Up @@ -212,7 +212,7 @@ impl<T: PriorityLevel, const N: usize, const L: usize> OrderedPool<T, N, L> {
///
/// The element is inserted unconditionally, and the least priority element is returned by
/// value.
pub(crate) fn force_insert(&mut self, new: T) -> Option<T> {
pub fn force_insert(&mut self, new: T) -> Option<T> {
let new_index = self.entries.len();
if new_index < N {
self.entries.push(new);
Expand Down

0 comments on commit d5c5160

Please sign in to comment.