Expand description
Capability trait for the external references a decoded view resolves. What a reader is allowed to ask the outside world for.
Turning engine integers into typed semantics means reaching things that live outside the file being read: a 2DA row, a line of display text, whether a referenced resource is actually there. Taking a concrete resource-mounting type instead would drag that whole layer into every crate that only wanted to parse and resolve bytes.
ContentSource is that seam. It lives in rakata-formats because it
returns a TwoDa, and formats is the lowest crate that can name one.
§Nothing consumes it today
The decoded views were its caller and they have been removed, pending a consumer that can state requirements. What keeps the seam here rather than deleting it with them is the ruling it was built for: “no install” is a source that answers nothing, not a second code path through every reader. If the decoded layer has not been rebuilt by the time the write path lands, this goes then.
§Capability is opt-in
Every method has a default body, so an implementor writes only the capabilities it has. A decode test hands in a map of tables and implements one method; an install-backed source implements all of them. A capability added here later breaks no implementor and no call site.
The defaults answer “I did not look”, never “no”. That distinction is
the reason ContentSource::resource_exists returns Option<bool>
rather than a bool: a source with no install behind it saying false
is a negative claim from something that never went looking, and a caller
cannot tell that apart from a real absence.
§Shape
Every method takes &mut self, including the read-only ones. Mixing
&self in buys nothing, because the borrow conflict callers hit comes
from holding a returned table, and that blocks a shared borrow exactly as
hard as a mutable one. Uniform &mut self leaves every capability free
to populate itself lazily, which is what an install-backed talk table
needs.
Only the table is returned borrowed. It is large and a resolver reads
several cells out of one row, so the borrow earns itself. Strings are
small and read once, and a second borrowing accessor would multiply the
inner-block dance Uti’s magnitude resolution already needs across every
view.
The trait is not object-safe, since the table lookup takes
impl AsRef<str>. Call sites take &mut impl ContentSource, so nothing
needs it to be.
Structs§
- NoSource
- A source that answers nothing.
Traits§
- Content
Source - Something a reader can resolve external references against.