Skip to main content

Module intern

Module intern 

Source
Expand description

Process-wide string interner used by crate::context::definition::Key.

Backed by lasso::ThreadedRodeo. Interned strings live for the lifetime of the program and are never freed.

§Untrusted input

Every term key of every parsed @context is interned, so the interner’s memory usage grows with the number of distinct context keys the process ever parses — a quantity that is attacker-controlled when parsing untrusted documents. A long-running service accepting arbitrary JSON-LD should bound the size of the documents it accepts (for example via Options::max_document_size on the reqwest loader of the main crate, or an equivalent limit at the transport layer) to keep this growth proportional to the traffic it chooses to serve.

Structs§

Spur
The default key for every Rodeo, uses only 32 bits of space

Functions§

intern
Interns the given string and returns its Spur.
intern_static
Interns the given string and returns the canonical &'static str directly.
interner
Returns the global interner, initializing it on first call.
resolve
Resolves a Spur back to its &'static str.
try_resolve
Resolves a Spur back to its &'static str, returning None if the key was never handed out by intern (e.g. forged via lasso::Key::try_from_usize).