Crate wasmcloud_actor_telnet[][src]

Telnet Server wasmCloud Actor Interface

This crate provides an abstraction over the wasmcloud:telnet contract. This allows actors to be notified when a new telnet session has started and when text has been received on a given session. Actors can also emit text to a specific session, which ultimately correlates to an individual connected socket client.

Example:

extern crate wasmcloud_actor_telnet as telnet;
extern crate wasmcloud_actor_core as actorcore;
use telnet::TelnetResult;
use wapc_guest::HandlerResult;

#[actorcore::init]
pub fn init() {
    telnet::Handlers::register_session_started(session_started);
    telnet::Handlers::register_receive_text(receive_text);
}

fn session_started(session: String) -> HandlerResult<TelnetResult> {
   let _ = telnet::default().send_text(session, "Welcome to the Interwebs!\n".to_string());
   Ok(TelnetResult {
     success: true,
     error: None,
   })
}
fn receive_text(session: String, text: String) -> HandlerResult<TelnetResult> {
   let _ = telnet::default().send_text(session, format!("Echo: {}\n", text));
   Ok(TelnetResult {
     success: true,
     error: None,
   })
}

Structs

Handlers
Host
ReceiveTextArgs
SendTextArgs
SessionStartedArgs
TelnetResult

Constants

OP_RECEIVE_TEXT
OP_SEND_TEXT
OP_SESSION_STARTED

Functions

default

Creates the default host binding for the telnet capability

deserialize

The standard function for de-serializing codec structs from a format suitable for message exchange between actor and host. Use of any other function to deserialize could result in breaking incompatibilities.

host

Creates a named host binding for the telnet capability

serialize

The standard function for serializing codec structs into a format that can be used for message exchange between actor and host. Use of any other function to serialize could result in breaking incompatibilities.