pub trait ContentSource {
// Provided methods
fn twoda(&mut self, name: impl AsRef<str>) -> Option<&TwoDa> { ... }
fn text(&mut self, strref: StrRef) -> Option<String> { ... }
fn voiceover(&mut self, strref: StrRef) -> Option<ResRef> { ... }
fn resource_exists(
&mut self,
resref: &ResRef,
resource_type: ResourceTypeCode,
) -> Option<bool> { ... }
}Expand description
Something a reader can resolve external references against.
See the module docs for why every method is defaulted and why the defaults are non-answers rather than falsy values.
Provided Methods§
Sourcefn twoda(&mut self, name: impl AsRef<str>) -> Option<&TwoDa>
fn twoda(&mut self, name: impl AsRef<str>) -> Option<&TwoDa>
Returns the named table, or None if it cannot be produced.
name is a bare table name with no .2da extension, so both a
&str literal and a TwoDaName constant work at the call site.
The None case merges “no such table” with “the table would not
parse”. A decoder falls back to raw values either way, and a caller
that needs to tell the two apart should ask the implementation
directly rather than route that through resolution.
Sourcefn text(&mut self, strref: StrRef) -> Option<String>
fn text(&mut self, strref: StrRef) -> Option<String>
Returns the display text a StrRef names.
None covers a source with no talk table behind it as well as a
StrRef that names no entry. A caller that got None displays the
raw StrRef.
Sourcefn voiceover(&mut self, strref: StrRef) -> Option<ResRef>
fn voiceover(&mut self, strref: StrRef) -> Option<ResRef>
Returns the voiceover resource a StrRef’s entry names.
Talk table entries carry a VO resref alongside their text, so this is a second read of the same entry rather than a separate lookup.
Sourcefn resource_exists(
&mut self,
resref: &ResRef,
resource_type: ResourceTypeCode,
) -> Option<bool>
fn resource_exists( &mut self, resref: &ResRef, resource_type: ResourceTypeCode, ) -> Option<bool>
Returns whether the named resource resolves.
None means this source cannot answer, which is not the same as
Some(false): a decoded view flagging a broken reference must not
treat “nobody looked” as “the resource is missing”.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.