Skip to content

Commit 9e02e7e

Browse files
committed
commentary
1 parent 655ab83 commit 9e02e7e

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

crates/core/src/host/module_host.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ pub struct CallViewParams {
546546
/// The expected return type of the view, used for deserialization.
547547
/// This type information is obtained from the [`ModuleDef`].
548548
pub return_type: AlgebraicType,
549+
/// Whether the view is being called anonymously (i.e., without a client identity).
549550
pub is_anonymous: bool,
550551
}
551552

crates/core/src/host/wasm_common/module_host_actor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ impl InstanceCommon {
726726
}
727727
}
728728

729+
/// Calls a function (reducer, view) and performs energy monitoring.
729730
fn call_function<F, R: FunctionResult>(
730731
&mut self,
731732
caller_identity: Identity,
@@ -768,6 +769,11 @@ impl InstanceCommon {
768769
(tx, result)
769770
}
770771

772+
/// Execute a view.
773+
///
774+
/// Similar to `call_reducer_with_tx`, but for views.
775+
/// unlike to `call_reducer_with_tx`, It does not handle `tx`creation or commit,
776+
/// It returns the updated `tx` instead.
771777
fn call_view_with_tx(
772778
&mut self,
773779
replica_ctx: &ReplicaContext,

crates/core/src/host/wasmtime/wasm_instance_env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const STANDARD_BYTES_SINK: u32 = 1;
126126
type WasmResult<T> = Result<T, WasmError>;
127127
type RtResult<T> = anyhow::Result<T>;
128128

129+
/// The type of function call being performed.
129130
pub enum FuncCallType {
130131
Reducer,
131132
Procedure,

crates/core/src/host/wasmtime/wasmtime_module.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ fn handle_error_sink_code(code: i32, error: Vec<u8>) -> Result<(), Box<str>> {
9797
}
9898
}
9999

100+
/// Handle the return code from a function using a result sink.
101+
///
102+
/// On success, returns the result bytes.
103+
/// On failure, returns the error message.
100104
fn handle_result_sink_code(code: i32, result: Vec<u8>) -> Result<Vec<u8>, Box<str>> {
101105
match code {
102106
0 => Ok(result),

crates/core/src/subscription/module_subscription_actor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl ModuleSubscriptions {
197197
}
198198
}
199199

200+
/// Should be called once to initialize the `ModuleSubscriptions` with a `ModuleHost` receiver.
200201
pub fn init(&self, module_host: watch::Receiver<ModuleHost>) {
201202
self.module_rx
202203
.set(module_host)

0 commit comments

Comments
 (0)