#[non_exhaustive]pub enum BytePageSize {
Size4 = 0,
Size8 = 1,
Size16 = 2,
Size24 = 3,
Size32 = 4,
Size48 = 5,
Size64 = 6,
Size128 = 7,
Size256 = 8,
Unset = 9,
}Expand description
Capacity category used when allocating crate::BytePage storage.
Buffers with a page size are returned to a per-thread cache of their
category when the last reference is dropped, see
crate::set_page_cache_size.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Size4 = 0
A 4 KiB page.
Size8 = 1
An 8 KiB page.
Size16 = 2
A 16 KiB page.
Size24 = 3
A 24 KiB page.
Size32 = 4
A 32 KiB page.
Size48 = 5
A 48 KiB page.
Size64 = 6
A 64 KiB page.
Size128 = 7
A 128 KiB page.
Size256 = 8
A 256 KiB page.
Unset = 9
No fixed page category.
Buffers of this category are sized on demand and never returned to
the page cache. A buffer whose allocation is exactly a page size
belongs to that page category, whichever way it was created. It
cannot be used as the page size of crate::BytePages.
Implementations§
Source§impl BytePageSize
impl BytePageSize
Sourcepub const fn for_capacity(capacity: usize) -> BytePageSize
pub const fn for_capacity(capacity: usize) -> BytePageSize
Returns the smallest page category with a capacity
of at least capacity bytes.
Returns BytePageSize::Unset if capacity is larger than the
capacity of the largest category.
§Examples
use ntex_bytes::BytePageSize;
assert_eq!(BytePageSize::for_capacity(100), BytePageSize::Size4);
assert_eq!(BytePageSize::for_capacity(5000), BytePageSize::Size8);
assert_eq!(BytePageSize::for_capacity(1024 * 1024), BytePageSize::Unset);Sourcepub const fn next(self) -> BytePageSize
pub const fn next(self) -> BytePageSize
Returns the next larger page category.
The largest category returns BytePageSize::Unset, Unset returns
itself.
Sourcepub const fn prev(self) -> BytePageSize
pub const fn prev(self) -> BytePageSize
Returns the next smaller page category.
The smallest category returns itself, BytePageSize::Unset returns
the largest category.
Sourcepub const fn capacity(self) -> usize
pub const fn capacity(self) -> usize
Returns the page capacity in bytes.
A page is allocated together with its header, the capacity is the category size minus the header, so the allocation is exactly the category size and fits the allocator’s size classes.
Sourcepub const fn half_capacity(self) -> usize
pub const fn half_capacity(self) -> usize
Returns the recommended write-buffer threshold for this page size.
This is half of the category size, but at most 16 KiB.
Sourcepub const fn low(self) -> usize
pub const fn low(self) -> usize
Returns the low free-capacity threshold for this page size.
This is 2/32 of the category size: 256 bytes for Size4, 1 KiB for
Size16, 16 KiB for Size256 and 4 KiB for BytePageSize::Unset.
crate::BytesMut::reserve_more grows a buffer once its remaining
capacity falls below it.
§Examples
use ntex_bytes::BytePageSize;
assert_eq!(BytePageSize::Size4.low(), 256);
assert_eq!(BytePageSize::Size8.low(), 512);
assert_eq!(BytePageSize::Size16.low(), 1024);
assert_eq!(BytePageSize::Unset.low(), 4096);Trait Implementations§
Source§impl Clone for BytePageSize
impl Clone for BytePageSize
Source§fn clone(&self) -> BytePageSize
fn clone(&self) -> BytePageSize
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BytePageSize
Source§impl Debug for BytePageSize
impl Debug for BytePageSize
Source§impl Default for BytePageSize
impl Default for BytePageSize
Source§fn default() -> BytePageSize
fn default() -> BytePageSize
impl Eq for BytePageSize
Source§impl PartialEq for BytePageSize
impl PartialEq for BytePageSize
impl StructuralPartialEq for BytePageSize
Auto Trait Implementations§
impl Freeze for BytePageSize
impl RefUnwindSafe for BytePageSize
impl Send for BytePageSize
impl Sync for BytePageSize
impl Unpin for BytePageSize
impl UnsafeUnpin for BytePageSize
impl UnwindSafe for BytePageSize
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.