[−]Struct astral::string::Subsystem
Manages optimized string allocation.
See the module-level documentation for more.
Methods
impl Subsystem<BuildHasherDefault<Murmur3>>
pub fn new(
max_strings: usize,
parent_logger: &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>
) -> Subsystem<BuildHasherDefault<Murmur3>>
max_strings: usize,
parent_logger: &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>
) -> Subsystem<BuildHasherDefault<Murmur3>>
Initialize the string subsystem with the specified capacity for unique strings.
Example
use astral::string; let string_subsystem = string::Subsystem::new(64, &logger);
impl<H> Subsystem<H> where
H: BuildHasher,
H: BuildHasher,
pub fn with_hasher(
max_strings: usize,
parent_logger: &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>,
hasher: H
) -> Subsystem<H>
max_strings: usize,
parent_logger: &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>,
hasher: H
) -> Subsystem<H>
Initialize the string subsystem with the specified capacity for unique strings, and a hasher.
Example
use std::hash::BuildHasherDefault; use astral::{ util::hash::Murmur3, string::{self, Text}, }; let hasher = BuildHasherDefault::<Murmur3>::default(); let string_subsystem = string::Subsystem::with_hasher(64, &logger, hasher); let text = Text::new("foo", &string_subsystem); assert_eq!(text, "foo");
impl<H> Subsystem<H>
pub fn used_memory(&self) -> usize
Returns the used memory.
Requires the track-strings
feature to be enabled.
pub fn allocations(&self) -> usize
Returns the used memory chunks.
Requires the track-strings
feature to be enabled.
pub fn strings_allocated(&self) -> usize
Returns the number of unique allocated strings.
Requires the track-strings
feature to be enabled.
pub fn average_string_length(&self) -> usize
Returns the average string length.
Requires the track-strings
feature to be enabled.
pub fn logger(
&self
) -> &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>
&self
) -> &Logger<Arc<dyn SendSyncRefUnwindSafeDrain<Err = NeverStruct, Ok = ()> + 'static>>
Returns the logger of this string subsystem.
Example
use astral::thirdparty::slog::info; use astral::string; let string_subsystem = string::Subsystem::new(64, &logger); info!(string_subsystem.logger(), "foo bar"; "additional" => "information");
Trait Implementations
impl<H> Sync for Subsystem<H>
impl<H> Send for Subsystem<H>
impl<H> Debug for Subsystem<H>
impl<H> Drop for Subsystem<H>
fn drop(&mut self)
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
T: Send + Sync + UnwindSafe + ?Sized,