Struct holochain::test_utils::host_fn_caller::HostFnCaller
source · pub struct HostFnCaller {
pub authored_db: DbWrite<DbKindAuthored>,
pub dht_db: DbWrite<DbKindDht>,
pub dht_db_cache: DhtDbQueryCache,
pub cache: DbWrite<DbKindCache>,
pub ribosome: RealRibosome,
pub zome_path: ZomePath,
pub network: HolochainP2pDna,
pub keystore: MetaLairClient,
pub signal_tx: SignalBroadcaster,
pub call_zome_handle: CellConductorReadHandle,
}
Expand description
A freely callable version of the host fn api, so that host functions can be called from Rust instead of Wasm
Fields§
§dht_db: DbWrite<DbKindDht>
§dht_db_cache: DhtDbQueryCache
§cache: DbWrite<DbKindCache>
§ribosome: RealRibosome
§zome_path: ZomePath
§network: HolochainP2pDna
§keystore: MetaLairClient
§signal_tx: SignalBroadcaster
§call_zome_handle: CellConductorReadHandle
Implementations§
source§impl HostFnCaller
impl HostFnCaller
sourcepub async fn create(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile
) -> HostFnCaller
pub async fn create(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile
) -> HostFnCaller
Create HostFnCaller for the first zome.
sourcepub async fn create_for_zome(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile,
zome_index: usize
) -> HostFnCaller
pub async fn create_for_zome(
cell_id: &CellId,
handle: &ConductorHandle,
dna_file: &DnaFile,
zome_index: usize
) -> HostFnCaller
Create HostFnCaller for a specific zome if there are multiple.
pub fn dht_db(&self) -> DbWrite<DbKindDht>
sourcepub async fn unpack(
&self
) -> (Arc<RealRibosome>, Arc<CallContext>, HostFnWorkspace)
pub async fn unpack(
&self
) -> (Arc<RealRibosome>, Arc<CallContext>, HostFnWorkspace)
Examples found in repository?
src/test_utils/host_fn_caller.rs (line 269)
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
pub async fn commit_entry<E: Into<EntryDefLocation>>(
&self,
entry: Entry,
entry_def_id: E,
visibility: EntryVisibility,
) -> ActionHash {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let input = CreateInput::new(
entry_def_id.into(),
visibility,
entry,
ChainTopOrdering::default(),
);
let output = host_fn::create::create(ribosome, call_context, input).unwrap();
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn delete_entry<'env>(&self, input: DeleteInput) -> ActionHash {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let output = {
let r = host_fn::delete::delete(ribosome, call_context, input);
let r = r.map_err(|e| {
debug!(%e);
e
});
r.unwrap()
};
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn update_entry(
&self,
entry: Entry,
original_action_address: ActionHash,
) -> ActionHash {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let input = UpdateInput {
original_action_address,
entry,
chain_top_ordering: Default::default(),
};
let output = { host_fn::update::update(ribosome, call_context, input).unwrap() };
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn get(&self, entry_hash: AnyDhtHash, options: GetOptions) -> Vec<Option<Record>> {
let (ribosome, call_context, _) = self.unpack().await;
let input = GetInput::new(entry_hash, options);
host_fn::get::get(ribosome, call_context, vec![input]).unwrap()
}
pub async fn get_details<'env>(
&self,
entry_hash: AnyDhtHash,
options: GetOptions,
) -> Vec<Option<Details>> {
let (ribosome, call_context, _) = self.unpack().await;
let input = GetInput::new(entry_hash, options);
host_fn::get_details::get_details(ribosome, call_context, vec![input]).unwrap()
}
pub async fn create_link<'env>(
&self,
base: AnyLinkableHash,
target: AnyLinkableHash,
zome_index: impl Into<ZomeIndex>,
link_type: impl Into<LinkType>,
link_tag: LinkTag,
) -> ActionHash {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let input = CreateLinkInput::new(
base,
target,
zome_index.into(),
link_type.into(),
link_tag,
ChainTopOrdering::default(),
);
let output = { host_fn::create_link::create_link(ribosome, call_context, input).unwrap() };
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn delete_link<'env>(&self, link_add_hash: ActionHash) -> ActionHash {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let output = {
host_fn::delete_link::delete_link(
ribosome,
call_context,
DeleteLinkInput::new(link_add_hash, ChainTopOrdering::default()),
)
.unwrap()
};
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn get_links<'env>(
&self,
base: AnyLinkableHash,
type_query: LinkTypeFilter,
link_tag: Option<LinkTag>,
_options: GetLinksOptions,
) -> Vec<Link> {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let input = GetLinksInput::new(base, type_query, link_tag);
let output = {
host_fn::get_links::get_links(ribosome, call_context, vec![input])
.unwrap()
.into_iter()
.next()
.unwrap()
};
// Write
workspace_lock.flush(&self.network).await.unwrap();
output
}
pub async fn get_link_details<'env>(
&self,
base: AnyLinkableHash,
type_query: LinkTypeFilter,
tag: LinkTag,
_options: GetLinksOptions,
) -> Vec<(SignedActionHashed, Vec<SignedActionHashed>)> {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let input = GetLinksInput::new(base, type_query, Some(tag));
let output = {
host_fn::get_link_details::get_link_details(ribosome, call_context, vec![input])
.unwrap()
.into_iter()
.next()
.unwrap()
};
// Write
workspace_lock.flush(&self.network).await.unwrap();
output.into()
}
pub async fn get_agent_activity(
&self,
agent: &AgentPubKey,
query: &ChainQueryFilter,
request: ActivityRequest,
) -> AgentActivity {
let (ribosome, call_context, _) = self.unpack().await;
let input = GetAgentActivityInput::new(agent.clone(), query.clone(), request);
host_fn::get_agent_activity::get_agent_activity(ribosome, call_context, input).unwrap()
}
pub async fn call_zome_direct(&self, invocation: ZomeCallInvocation) -> ExternIO {
let (ribosome, call_context, workspace_lock) = self.unpack().await;
let (_, output) = {
let host_access = call_context.host_context();
let zcha = unwrap_to!(host_access => HostContext::ZomeCall).clone();
call_zome_function_authorized((*ribosome).clone(), zcha, invocation)
.await
.unwrap()
};
// Write
workspace_lock.flush(&self.network).await.unwrap();
unwrap_to!(output.unwrap() => ZomeCallResponse::Ok).to_owned()
}
source§impl HostFnCaller
impl HostFnCaller
pub fn get_entry_type(
&self,
zome: impl Into<TestWasmPair<ZomeName>>,
index: impl Into<EntryDefIndex>
) -> ScopedEntryDefIndex
pub fn get_entry_link(
&self,
zome: impl Into<TestWasmPair<ZomeName>>,
index: impl Into<LinkType>
) -> ScopedLinkType
pub async fn commit_entry<E: Into<EntryDefLocation>>(
&self,
entry: Entry,
entry_def_id: E,
visibility: EntryVisibility
) -> ActionHash
pub async fn delete_entry<'env>(&self, input: DeleteInput) -> ActionHash
pub async fn update_entry(
&self,
entry: Entry,
original_action_address: ActionHash
) -> ActionHash
pub async fn get(
&self,
entry_hash: AnyDhtHash,
options: GetOptions
) -> Vec<Option<Record>> ⓘ
pub async fn get_details<'env>(
&self,
entry_hash: AnyDhtHash,
options: GetOptions
) -> Vec<Option<Details>> ⓘ
pub async fn create_link<'env>(
&self,
base: AnyLinkableHash,
target: AnyLinkableHash,
zome_index: impl Into<ZomeIndex>,
link_type: impl Into<LinkType>,
link_tag: LinkTag
) -> ActionHash
pub async fn delete_link<'env>(&self, link_add_hash: ActionHash) -> ActionHash
pub async fn get_links<'env>(
&self,
base: AnyLinkableHash,
type_query: LinkTypeFilter,
link_tag: Option<LinkTag>,
_options: GetLinksOptions
) -> Vec<Link> ⓘ
pub async fn get_link_details<'env>(
&self,
base: AnyLinkableHash,
type_query: LinkTypeFilter,
tag: LinkTag,
_options: GetLinksOptions
) -> Vec<(SignedActionHashed, Vec<SignedActionHashed>)> ⓘ
pub async fn get_agent_activity(
&self,
agent: &AgentPubKey,
query: &ChainQueryFilter,
request: ActivityRequest
) -> AgentActivity
pub async fn call_zome_direct(&self, invocation: ZomeCallInvocation) -> ExternIO
Trait Implementations§
source§impl Clone for HostFnCaller
impl Clone for HostFnCaller
source§fn clone(&self) -> HostFnCaller
fn clone(&self) -> HostFnCaller
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HostFnCaller
impl Send for HostFnCaller
impl Sync for HostFnCaller
impl Unpin for HostFnCaller
impl !UnwindSafe for HostFnCaller
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