Skip to main content

ProviderChain

Struct ProviderChain 

Source
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

Source

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.

Source

pub const DEFAULT_CACHE_BYTES: u64

The cache’s default bound in bytes.

Source

pub fn empty() -> Self

No providers: stripped objects are no_typetree.

Source

pub fn new(providers: Vec<Arc<dyn TypeTreeProvider>>) -> Self

Providers asked in order; the first answer wins. The cache has the default bounds.

Source

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).

Source

pub fn is_empty(&self) -> bool

Whether the chain has no provider.

Source

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.

Source

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).

Source

pub fn cached(&self) -> usize

Answers cached now.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ProviderChain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProviderChain

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.