Skip to main content

Resolver

Struct Resolver 

Source
pub struct Resolver<'a, ArtCan, BCan: CanStrong, DynState = ()> { /* private fields */ }
Expand description

Resolves dependent Artifacts for Builders.

This struct is only available to the build method of Builders. It is specific to that Builder, which will be referred to as the owning Builder. The Resolver provides limited access to the Cache for which the owning Builder builds its Artifact. This access is limited to the dynamic state of the owning Builder and the Artifacts of other builders.

This concept of a specific Resolver serves the important purpose of tracking dependencies between Artifacts. Thus all Artifacts which are retrieved through a Resolver create a dependency of the Artifact of the owning Builder upon the resolved Artifact.

These tracked dependencies are used to correctly implement the Artifact invalidation of the Cache through Cache::invalidate.

Implementations§

Source§

impl<'a, ArtCan, BCan, DynState> Resolver<'a, ArtCan, BCan, DynState>
where ArtCan: Debug, BCan: CanStrong, DynState: 'static,

Source

pub fn resolve<AP, B>(&mut self, promise: &AP) -> Result<ArtCan::Bin, B::Err>
where ArtCan: CanSized<B::Artifact> + Clone, B: Builder<ArtCan, BCan> + ?Sized, BCan: Can<AP::Builder>, AP: Promise<Builder = B, BCan = BCan>,

Resolves an Artifact to its Bin.

Returns the Artifact in its Bin. That is an Rc<B::Artifact> when using the rc module. The Bin is useful to share an identical artifact or one that is not Clone when an owned value is required or lifetime errors occur using resolve_ref.

This method will try to build the Artifact if it is not stored in the corresponding Cache. The building using that Builder’s build method could fail, thus a Result is returned. An Err will be returned only, if the Artifact was not cached and the Builder returned an Err.

Also see the corresponding get method of Cache.

Source

pub fn resolve_ref<AP, B>( &mut self, promise: &AP, ) -> Result<&B::Artifact, B::Err>
where ArtCan: CanRef<B::Artifact>, B: Builder<ArtCan, BCan> + ?Sized, BCan: Can<AP::Builder>, AP: Promise<Builder = B, BCan = BCan>,

Resolves an Artifact by reference.

Returns the Artifact as reference into the corresponding Cache. The reference is useful to access artifact for short time, as it dose not incur any cloning overhead, thus it is the cheapest way to access an Artifact, and should be preferred wherever possible.

When an owned value is required instead or lifetime issues arise, resolve and resolve_cloned are alternatives, which return a clone of the Artifact Bin or of the Artifact itself, respectively.

This method will try to build the Artifact if it is not stored in the Cache. The building using the Builder’s build method could fail, thus a Result is returned. An Err will be returned only, if the Artifact was not cached and the Builder returned an Err.

Also see the corresponding get_ref method of Cache.

Source

pub fn resolve_cloned<AP, B>( &mut self, promise: &AP, ) -> Result<B::Artifact, B::Err>
where ArtCan: CanRef<B::Artifact>, B: Builder<ArtCan, BCan> + ?Sized, B::Artifact: Clone, BCan: Can<AP::Builder>, AP: Promise<Builder = B, BCan = BCan>,

Resolves an Artifact into a clone of it.

Returns a clone of the Artifact. The clone is useful when cloning the Artifact itself is viable and an owned value is required or lifetime errors occur using resolve_ref.

This method will try to build the Artifact if it is not stored in the Cache. The building using the Builder’s build method could fail, thus a Result is returned. An Err will be returned only, if the Artifact was not cached and the Builder returned an Err.

Also see the corresponding get_cloned method of Cache.

Source

pub fn my_state(&mut self) -> &mut DynState

Returns the dynamic state of the owning Builder.

Notice, when an Artifact needs to be builded, the dynamic state of the respective Builder will be initialized preventively, thus this method wan always return a dynamic state without the need to create it. In other words when an Artifact is build, it will get an dynamic state, regardless wether this method or and other dynamic state accessor is ever called.

Auto Trait Implementations§

§

impl<'a, ArtCan, BCan, DynState> Freeze for Resolver<'a, ArtCan, BCan, DynState>

§

impl<'a, ArtCan, BCan, DynState = ()> !RefUnwindSafe for Resolver<'a, ArtCan, BCan, DynState>

§

impl<'a, ArtCan, BCan, DynState = ()> !Send for Resolver<'a, ArtCan, BCan, DynState>

§

impl<'a, ArtCan, BCan, DynState = ()> !Sync for Resolver<'a, ArtCan, BCan, DynState>

§

impl<'a, ArtCan, BCan, DynState> Unpin for Resolver<'a, ArtCan, BCan, DynState>
where DynState: Unpin,

§

impl<'a, ArtCan, BCan, DynState> UnsafeUnpin for Resolver<'a, ArtCan, BCan, DynState>

§

impl<'a, ArtCan, BCan, DynState = ()> !UnwindSafe for Resolver<'a, ArtCan, BCan, DynState>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.