Struct ICodeBehindBase
pub struct ICodeBehindBase(/* private fields */);Implementations§
§impl ICodeBehindBase
impl ICodeBehindBase
pub fn attach_override(&self) -> Result<(), Error>
pub fn detach_override(&self) -> Result<(), Error>
§impl ICodeBehindBase
impl ICodeBehindBase
pub fn register_command(
&self,
command_name: impl AsRef<KanziStr>,
closure: impl Handler,
) -> Result<(), Error>
pub fn register_command( &self, command_name: impl AsRef<KanziStr>, closure: impl Handler, ) -> Result<(), Error>
Registers a new command handler.
A command is a form of user input.
The code behind class of a node can register a handler for a command and perform an operation in the handler.
You must call this method in register_commands_override.
§Arguments
command_name- The name of the command that you want to handle.closure- The handler functor for the command.
pub fn unregister_command(
&self,
command_name: impl AsRef<KanziStr>,
) -> Result<(), Error>
pub fn unregister_command( &self, command_name: impl AsRef<KanziStr>, ) -> Result<(), Error>
Unregisters a command handler.
You must call this method in unregister_commands_override.
§Arguments
command_name- The name of the command for which you previously registered a handler.
Methods from Deref<Target = INodeComponentBase>§
pub fn attach_override(&self) -> Result<(), Error>
pub fn detach_override(&self) -> Result<(), Error>
pub fn add_message_handler<T>(
&self,
message_type: &MessageType<T>,
closure: impl Handler,
) -> Result<MessageSubscriptionToken, Error>
pub fn add_message_handler<T>( &self, message_type: &MessageType<T>, closure: impl Handler, ) -> Result<MessageSubscriptionToken, Error>
Kanzi calls the message handler that you add using this function when the target name of the incoming message matches the name of this node component, or if the message is broadcast to all node components with an empty target name.
§Arguments
message_type- Type of message to handle.closure- The callback that will be invoked when this node component receives a message.
§Returns
Message subscription token.
pub fn remove_message_filter(
&self,
token: &MessageSubscriptionToken,
) -> Result<(), Error>
pub fn remove_message_filter( &self, token: &MessageSubscriptionToken, ) -> Result<(), Error>
Removes message handler added via add_message_handler function.
§Arguments
token- Subscription token of message handler to remove.
pub fn dispatch_message<T>(
&self,
message_type: &MessageType<T>,
message_arguments: &T,
) -> Result<(), Error>where
T: MessageArgumentsConstraint,
pub fn dispatch_message<T>(
&self,
message_type: &MessageType<T>,
message_arguments: &T,
) -> Result<(), Error>where
T: MessageArgumentsConstraint,
Adds the name of the node component to the message arguments and dispatches the message to the node of the node component.
§Arguments
message_type- The type of the dispatched message.message_arguments- The arguments of the dispatched message.
pub fn dispatch_abstract_message<T>(
&self,
message_type: &MessageType<T>,
message_arguments: &MessageArguments,
) -> Result<(), Error>
pub fn dispatch_abstract_message<T>( &self, message_type: &MessageType<T>, message_arguments: &MessageArguments, ) -> Result<(), Error>
Adds the name of the node component to the abstract message arguments and dispatches the message to the node of the node component.
§Arguments
message_type- The abstract type of the dispatched message.message_arguments- The abstract arguments of the dispatched message.