pub struct Status {
pub size: usize,
pub idle: usize,
pub in_use: usize,
pub max_size: usize,
}Available on crate feature
std only.Expand description
A snapshot of how many resources a Pool holds.
Returned by Pool::status. The counts are read under
the pool’s lock, but in a concurrent program they are stale the instant they
are returned — treat them as a gauge for logging and metrics, not as a value
to branch on for correctness.
The invariant size == idle + in_use holds for each individual snapshot.
§Examples
use pool_mod::{Manager, Pool};
use std::convert::Infallible;
struct Nothing;
impl Manager for Nothing {
type Resource = ();
type Error = Infallible;
fn create(&self) -> Result<(), Infallible> { Ok(()) }
fn recycle(&self, _r: &mut ()) -> Result<(), Infallible> { Ok(()) }
}
let pool = Pool::builder(Nothing).max_size(4).min_idle(2).build()
.expect("configuration is valid");
let status = pool.status();
assert_eq!(status.size, 2);
assert_eq!(status.idle, 2);
assert_eq!(status.in_use, 0);
assert_eq!(status.max_size, 4);
assert_eq!(status.size, status.idle + status.in_use);Fields§
§size: usizeTotal resources the pool owns right now: idle, plus checked out, plus any currently being created.
idle: usizeResources sitting idle and available for immediate checkout.
in_use: usizeResources currently lent out to callers (counted as size - idle, which
folds in-flight creations into the in-use figure).
max_size: usizeThe configured max_size the pool will not grow beyond.
Trait Implementations§
impl Copy for Status
impl Eq for Status
impl StructuralPartialEq for Status
Auto Trait Implementations§
impl Freeze for Status
impl RefUnwindSafe for Status
impl Send for Status
impl Sync for Status
impl Unpin for Status
impl UnsafeUnpin for Status
impl UnwindSafe for Status
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more