pub struct SweetZome { /* private fields */ }
Expand description
A reference to a Zome in a Cell created by a SweetConductor installation function. Think of it as a partially applied SweetCell, with the ZomeName baked in.
Implementations§
source§impl SweetZome
impl SweetZome
sourcepub fn cell_id(&self) -> &CellId
pub fn cell_id(&self) -> &CellId
Accessor
Examples found in repository?
src/sweettest/sweet_conductor_handle.rs (line 38)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
pub async fn call_fallible<I, O, F>(
&self,
zome: &SweetZome,
fn_name: F,
payload: I,
) -> ConductorApiResult<O>
where
FunctionName: From<F>,
I: serde::Serialize + std::fmt::Debug,
O: serde::de::DeserializeOwned + std::fmt::Debug,
{
self.call_from_fallible(zome.cell_id().agent_pubkey(), None, zome, fn_name, payload)
.await
}
/// Make a zome call to a Cell, as if some other Cell were the caller. More general case.
/// Can optionally provide a capability.
pub async fn call_from<I, O, F>(
&self,
provenance: &AgentPubKey,
cap_secret: Option<CapSecret>,
zome: &SweetZome,
fn_name: F,
payload: I,
) -> O
where
FunctionName: From<F>,
I: Serialize + std::fmt::Debug,
O: serde::de::DeserializeOwned + std::fmt::Debug,
{
self.call_from_fallible(provenance, cap_secret, zome, fn_name, payload)
.await
.unwrap()
}
/// Like `call_from`, but without the unwrap
pub async fn call_from_fallible<I, O, F>(
&self,
provenance: &AgentPubKey,
cap_secret: Option<CapSecret>,
zome: &SweetZome,
fn_name: F,
payload: I,
) -> ConductorApiResult<O>
where
FunctionName: From<F>,
I: Serialize + std::fmt::Debug,
O: serde::de::DeserializeOwned + std::fmt::Debug,
{
let payload = ExternIO::encode(payload).expect("Couldn't serialize payload");
let now = Timestamp::now();
let (nonce, expires_at) = fresh_nonce(now)?;
let call_unsigned = ZomeCallUnsigned {
cell_id: zome.cell_id().clone(),
zome_name: zome.name().clone(),
fn_name: fn_name.into(),
cap_secret,
provenance: provenance.clone(),
payload,
nonce,
expires_at,
};
let call = ZomeCall::try_from_unsigned_zome_call(self.keystore(), call_unsigned).await?;
let response = self.0.call_zome(call).await;
match response {
Ok(Ok(response)) => Ok(unwrap_to!(response => ZomeCallResponse::Ok)
.decode()
.expect("Couldn't deserialize zome call output")),
Ok(Err(error)) => Err(ConductorApiError::Other(Box::new(error))),
Err(error) => Err(error),
}
}
sourcepub fn name(&self) -> &ZomeName
pub fn name(&self) -> &ZomeName
Accessor
Examples found in repository?
src/sweettest/sweet_conductor_handle.rs (line 80)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
pub async fn call_from_fallible<I, O, F>(
&self,
provenance: &AgentPubKey,
cap_secret: Option<CapSecret>,
zome: &SweetZome,
fn_name: F,
payload: I,
) -> ConductorApiResult<O>
where
FunctionName: From<F>,
I: Serialize + std::fmt::Debug,
O: serde::de::DeserializeOwned + std::fmt::Debug,
{
let payload = ExternIO::encode(payload).expect("Couldn't serialize payload");
let now = Timestamp::now();
let (nonce, expires_at) = fresh_nonce(now)?;
let call_unsigned = ZomeCallUnsigned {
cell_id: zome.cell_id().clone(),
zome_name: zome.name().clone(),
fn_name: fn_name.into(),
cap_secret,
provenance: provenance.clone(),
payload,
nonce,
expires_at,
};
let call = ZomeCall::try_from_unsigned_zome_call(self.keystore(), call_unsigned).await?;
let response = self.0.call_zome(call).await;
match response {
Ok(Ok(response)) => Ok(unwrap_to!(response => ZomeCallResponse::Ok)
.decode()
.expect("Couldn't deserialize zome call output")),
Ok(Err(error)) => Err(ConductorApiError::Other(Box::new(error))),
Err(error) => Err(error),
}
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for SweetZome
impl Send for SweetZome
impl Sync for SweetZome
impl Unpin for SweetZome
impl UnwindSafe for SweetZome
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove
Any::type_id_compat and use StdAny::type_id instead.
https://github.com/rust-lang/rust/issues/27745
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref