1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/// A string buffer type.
///
/// Used at [`Formatter`].
///
/// By default, it is an alias for [`String`], if feature `flexible-string` is
/// enabled, an internal type `FlexibleString` will be used.
///
/// `FlexibleString` has a fixed stack buffer of 256 bytes, and upgrades to
/// [`String`] when more space is needed. It provides APIs that are as
/// consistent as possible with [`String`], but some APIs are not yet
/// implemented or not possible to be implemented.
///
/// <div class="warning">
///
/// `FlexibleString` can improve performance as it avoids memory allocation when
/// formatting records as much as possible, however it contains unsafe code that
/// has not been strictly reviewed.
///
/// </div>
///
/// [`Sink`]: crate::sink::Sink
/// [`Formatter`]: crate::formatter::Formatter
pub type StringBuf = StringBufInner;
// Users should not use the following types directly.
// pub for hide type alias in doc
pub type StringBufInner = FlexibleString;
// same as above
pub type StringBufInner = String;
pub const STACK_SIZE: usize = 256;
pub const RESERVE_SIZE: usize = STACK_SIZE / 2;