pub struct ProviderChain { /* private fields */ }Expand description
Providers in order, with a bounded cache of their answers keyed by
(class, packed version, script) (module docs).
Implementations§
Source§impl ProviderChain
impl ProviderChain
Sourcepub const DEFAULT_CACHE_ENTRIES: usize
pub const DEFAULT_CACHE_ENTRIES: usize
The cache’s default bound in entries: far more than a TPK has classes at the versions one run meets.
Sourcepub const DEFAULT_CACHE_BYTES: u64
pub const DEFAULT_CACHE_BYTES: u64
The cache’s default bound in bytes.
Sourcepub fn new(providers: Vec<Arc<dyn TypeTreeProvider>>) -> Self
pub fn new(providers: Vec<Arc<dyn TypeTreeProvider>>) -> Self
Providers asked in order; the first answer wins. The cache has the default bounds.
Sourcepub fn with_cache_bound(
providers: Vec<Arc<dyn TypeTreeProvider>>,
entries: usize,
bytes: u64,
) -> Self
pub fn with_cache_bound( providers: Vec<Arc<dyn TypeTreeProvider>>, entries: usize, bytes: u64, ) -> Self
Providers asked in order, with a cache of at most entries answers
and bytes bytes (each entry costs its slot, at the table’s worst load,
plus the heap its key owns).
Sourcepub fn accepts_scripts(&self) -> bool
pub fn accepts_scripts(&self) -> bool
Whether a provider answers script requests (UnityPy has an
env.typetree_generator): only then does
crate::env::Environment::object_tree dereference m_Script.
Sourcepub fn common_strings(&self) -> Option<&CommonStrings>
pub fn common_strings(&self) -> Option<&CommonStrings>
The common strings of the first provider that has them, which blob
typetrees read in place of crate::typetree::commonstring::COMMON_STRINGS
(UnityPy reads its TPK’s).
Sourcepub fn lookup(
&self,
req: &TreeRequest<'_>,
) -> Result<Option<TreeRef>, ProviderError>
pub fn lookup( &self, req: &TreeRequest<'_>, ) -> Result<Option<TreeRef>, ProviderError>
The first provider’s answer for req. An answer is cached while the
cache has room; a miss is not cached. Providers are asked with no lock
held. A script request asks only the providers that
TypeTreeProvider::accepts_scripts: UnityPy asks its
typetree_generator alone for a script’s tree
(files/ObjectReader.py:346-350), never the TPK, whose class tree is
the one the request would replace.
Sourcepub fn why_none(
&self,
class_id: i32,
version: Option<&UnityVersion>,
) -> Option<NoTree>
pub fn why_none( &self, class_id: i32, version: Option<&UnityVersion>, ) -> Option<NoTree>
Why no provider answers the class tree of class_id at version
(TypeTreeProvider::why_none): the reason of the last provider
that states one, the one a fallback that raised in turn would leave
(UnityPy has one TPK). Asked only where Self::lookup found none;
nothing is cached.