pub struct InternScope { /* private fields */ }Expand description
A StringInterner installed for the duration of a deserialization.
InternedStr fields built while it is in scope share one Arc<str> per
distinct string, rather than being deduplicated by a second pass
afterwards.
The cache-hit path used to do both halves of that: rkyv handed every
occurrence its own fresh Arc (40,015 of them for a ledger with a few
dozen distinct strings), and reintern_directives then walked every
directive again to collapse them. Interning on the way in makes the walk
unnecessary — it establishes exactly the postcondition that pass exists to
guarantee, that equal strings share a pointer.
Scoped rather than process-wide on purpose: an interner that outlives the
call would accumulate every distinct payee and narration a long-running
LSP or FFI host had ever seen, and this crate already offers explicit
StringInterner / AccountInterner for callers that want to own one.
The table here is dropped with the guard; the Arcs it handed out live on
in the deserialized values, which is the whole point.
Nesting is safe: an inner scope observes that one is already installed, leaves it in place, and is a no-op on drop, so the outer scope keeps interning through to its own end.
Implementations§
Source§impl InternScope
impl InternScope
Trait Implementations§
Source§impl Default for InternScope
Available on crate feature rkyv only.
impl Default for InternScope
rkyv only.Source§impl Drop for InternScope
Available on crate feature rkyv only.
impl Drop for InternScope
rkyv only.Auto Trait Implementations§
impl Freeze for InternScope
impl RefUnwindSafe for InternScope
impl Send for InternScope
impl Sync for InternScope
impl Unpin for InternScope
impl UnsafeUnpin for InternScope
impl UnwindSafe for InternScope
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.