pub trait Ctx: Debug + 'static {
Show 16 methods
// Required methods
fn clear(&mut self);
fn subscribe(
&mut self,
flags: UpdatesFlags,
path: Path,
ref_by: ExprId,
) -> Dval;
fn unsubscribe(&mut self, path: Path, dv: Dval, ref_by: ExprId);
fn list(&mut self, id: BindId, path: Path);
fn list_table(&mut self, id: BindId, path: Path);
fn stop_list(&mut self, id: BindId);
fn publish(
&mut self,
path: Path,
value: Value,
ref_by: ExprId,
) -> Result<Val>;
fn update(&mut self, id: &Val, value: Value);
fn unpublish(&mut self, id: Val, ref_by: ExprId);
fn ref_var(&mut self, id: BindId, ref_by: ExprId);
fn unref_var(&mut self, id: BindId, ref_by: ExprId);
fn set_var(&mut self, id: BindId, value: Value);
fn call_rpc(&mut self, name: Path, args: Vec<(ArcStr, Value)>, id: BindId);
fn publish_rpc(
&mut self,
name: Path,
doc: Value,
spec: Vec<ArgSpec>,
id: BindId,
) -> Result<()>;
fn unpublish_rpc(&mut self, name: Path);
fn set_timer(&mut self, id: BindId, timeout: Duration);
}
Required Methods§
fn clear(&mut self)
Sourcefn subscribe(&mut self, flags: UpdatesFlags, path: Path, ref_by: ExprId) -> Dval
fn subscribe(&mut self, flags: UpdatesFlags, path: Path, ref_by: ExprId) -> Dval
Subscribe to the specified netidx path. When the subscription updates you are expected to deliver Netidx events to the expression specified by ref_by.
Sourcefn unsubscribe(&mut self, path: Path, dv: Dval, ref_by: ExprId)
fn unsubscribe(&mut self, path: Path, dv: Dval, ref_by: ExprId)
Called when a subscription is no longer needed
Sourcefn list(&mut self, id: BindId, path: Path)
fn list(&mut self, id: BindId, path: Path)
List the netidx path, return Value::Null if the path did not change. When the path did update you should send the output back as a properly formatted struct with two fields, rows and columns both containing string arrays.
Sourcefn list_table(&mut self, id: BindId, path: Path)
fn list_table(&mut self, id: BindId, path: Path)
List the table at path, return Value::Null if the path did not change
Sourcefn stop_list(&mut self, id: BindId)
fn stop_list(&mut self, id: BindId)
list or table will no longer be called on this BindId, and related resources can be cleaned up.
Sourcefn publish(&mut self, path: Path, value: Value, ref_by: ExprId) -> Result<Val>
fn publish(&mut self, path: Path, value: Value, ref_by: ExprId) -> Result<Val>
Publish the specified value, returning it’s Id, which must be used to update the value and unpublish it. If the path is already published, return an error.
Sourcefn ref_var(&mut self, id: BindId, ref_by: ExprId)
fn ref_var(&mut self, id: BindId, ref_by: ExprId)
This will be called by the compiler whenever a bound variable is referenced. The ref_by is the toplevel expression that contains the variable reference. When a variable event happens, you should update all the toplevel expressions that ref that variable.
ref_var will also be called when a bound lambda expression is referenced, in that case the ref_by id will be the toplevel expression containing the call site.
fn unref_var(&mut self, id: BindId, ref_by: ExprId)
Sourcefn set_var(&mut self, id: BindId, value: Value)
fn set_var(&mut self, id: BindId, value: Value)
Called by the ExecCtx when set_var is called on it. All expressions that ref the id should be updated when this happens.
The runtime must deliver all set_vars in a single event except that set_vars for the same variable in the same cycle must be queued and deferred to the next cycle.
The runtime MUST NOT change event while a cycle is in progress. set_var must be queued until the cycle ends and then presented as a new batch.
Sourcefn call_rpc(&mut self, name: Path, args: Vec<(ArcStr, Value)>, id: BindId)
fn call_rpc(&mut self, name: Path, args: Vec<(ArcStr, Value)>, id: BindId)
This must return results from the same path in the call order.
when the rpc returns you are expected to deliver a Variable event with the specified id to the expression specified by ref_by.
Sourcefn publish_rpc(
&mut self,
name: Path,
doc: Value,
spec: Vec<ArgSpec>,
id: BindId,
) -> Result<()>
fn publish_rpc( &mut self, name: Path, doc: Value, spec: Vec<ArgSpec>, id: BindId, ) -> Result<()>
Publish an rpc at the specified path with the specified procedure level doc and arg spec.
When the RPC is called the rpc table in event will be populated under the specified bind id.
If the procedure is already published an error will be returned
Sourcefn unpublish_rpc(&mut self, name: Path)
fn unpublish_rpc(&mut self, name: Path)
unpublish the rpc identified by the bind id.