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>
impl<'a, ArtCan, BCan, DynState> Resolver<'a, ArtCan, BCan, DynState>
Sourcepub fn resolve<AP, B>(&mut self, promise: &AP) -> Result<ArtCan::Bin, B::Err>
pub fn resolve<AP, B>(&mut self, promise: &AP) -> Result<ArtCan::Bin, B::Err>
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.
Sourcepub fn resolve_ref<AP, B>(
&mut self,
promise: &AP,
) -> Result<&B::Artifact, B::Err>
pub fn resolve_ref<AP, B>( &mut self, promise: &AP, ) -> Result<&B::Artifact, B::Err>
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.
Sourcepub fn resolve_cloned<AP, B>(
&mut self,
promise: &AP,
) -> Result<B::Artifact, B::Err>
pub fn resolve_cloned<AP, B>( &mut self, promise: &AP, ) -> Result<B::Artifact, B::Err>
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.
Sourcepub fn my_state(&mut self) -> &mut DynState
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.