[]Struct astral::string::Subsystem

pub struct Subsystem<H = BuildHasherDefault<Murmur3>> { /* fields omitted */ }

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>>

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

pub fn with_hasher(
    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>>

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>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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.

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized