pub struct Resolver<S> { /* private fields */ }
Expand description
The Resolver is responsible for providing information about types. It relies on its internal
package_store
to load packages and then type definitions from those packages.
Implementations§
Source§impl<S> Resolver<S>
impl<S> Resolver<S>
pub fn new(package_store: S) -> Self
pub fn new_with_limits(package_store: S, limits: Limits) -> Self
pub fn package_store(&self) -> &S
pub fn package_store_mut(&mut self) -> &mut S
Source§impl<S: PackageStore> Resolver<S>
impl<S: PackageStore> Resolver<S>
Sourcepub async fn canonical_type(&self, tag: TypeTag) -> Result<TypeTag>
pub async fn canonical_type(&self, tag: TypeTag) -> Result<TypeTag>
The canonical form of a type refers to each type in terms of its defining package ID. This function takes a non-canonical type and updates all its package IDs to the appropriate defining ID.
For every package::module::datatype
in the input tag
, package
must be an object
on-chain, containing a move package that includes module
, and that module must define the
datatype
. In practice this means the input type tag
can refer to types at or after
their defining IDs.
Sourcepub async fn type_layout(&self, tag: TypeTag) -> Result<MoveTypeLayout>
pub async fn type_layout(&self, tag: TypeTag) -> Result<MoveTypeLayout>
Return the type layout corresponding to the given type tag. The layout always refers to structs in terms of their defining ID (i.e. their package ID always points to the first package that introduced them).
Sourcepub async fn abilities(&self, tag: TypeTag) -> Result<AbilitySet>
pub async fn abilities(&self, tag: TypeTag) -> Result<AbilitySet>
Return the abilities of a concrete type, based on the abilities in its type definition, and
the abilities of its concrete type parameters: An instance of a generic type has store
,
copy, or
dropif its definition has the ability, and all its non-phantom type parameters have the ability as well. Similar rules apply for
keyexcept that it requires its type parameters to have
store`.
Sourcepub async fn function_signature(
&self,
pkg: AccountAddress,
module: &str,
function: &str,
) -> Result<FunctionDef>
pub async fn function_signature( &self, pkg: AccountAddress, module: &str, function: &str, ) -> Result<FunctionDef>
Returns the signatures of parameters to function pkg::module::function
in the package
store, assuming the function exists.
Sourcepub async fn pure_input_layouts(
&self,
tx: &ProgrammableTransaction,
) -> Result<Vec<Option<MoveTypeLayout>>>
pub async fn pure_input_layouts( &self, tx: &ProgrammableTransaction, ) -> Result<Vec<Option<MoveTypeLayout>>>
Attempts to infer the type layouts for pure inputs to the programmable transaction.
The returned vector contains an element for each input to tx
. Elements corresponding to
pure inputs that are used as arguments to transaction commands will contain Some(layout)
.
Elements for other inputs (non-pure inputs, and unused pure inputs) will be None
.
Layout resolution can fail if a type/module/package doesn’t exist, if layout resolution hits a limit, or if a pure input is somehow used in multiple conflicting occasions (with different types).
Sourcepub async fn resolve_module_id(
&self,
module_id: ModuleId,
context: AccountAddress,
) -> Result<ModuleId>
pub async fn resolve_module_id( &self, module_id: ModuleId, context: AccountAddress, ) -> Result<ModuleId>
Resolves a runtime address in a ModuleId
to a storage ModuleId
according to the linkage
table in the context
which must refer to a package.
- Will fail if the wrong context is provided, i.e., is not a package, or does not exist.
- Will fail if an invalid
context
is provided for thelocation
, i.e., the package atcontext
does not contain the module thatlocation
refers to.
Sourcepub async fn resolve_clever_error(
&self,
module_id: ModuleId,
abort_code: u64,
) -> Option<CleverError>
pub async fn resolve_clever_error( &self, module_id: ModuleId, abort_code: u64, ) -> Option<CleverError>
Resolves an abort code following the clever error format to a CleverError
enum.
The module_id
must be the storage ID of the module (which can e.g., be gotten from the
resolve_module_id
function) and not the runtime ID.
If the abort_code
is not a clever error (i.e., does not follow the tagging and layout as
defined in ErrorBitset
), this function will return None
.
In the case where it is a clever error but only a line number is present (i.e., the error
is the result of an assert!(<cond>)
source expression) a CleverError::LineNumberOnly
is
returned. Otherwise a CleverError::CompleteError
is returned.
If for any reason we are unable to resolve the abort code to a CleverError
, this function
will return None
.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Resolver<S>where
S: Freeze,
impl<S> RefUnwindSafe for Resolver<S>where
S: RefUnwindSafe,
impl<S> Send for Resolver<S>where
S: Send,
impl<S> Sync for Resolver<S>where
S: Sync,
impl<S> Unpin for Resolver<S>where
S: Unpin,
impl<S> UnwindSafe for Resolver<S>where
S: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a Request
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.