pub struct TernNode {
pub addr: String,
/* private fields */
}Expand description
The ternlang distributed node. Manages local agent mailboxes and TCP connections to peer nodes.
Fields§
§addr: StringImplementations§
Source§impl TernNode
impl TernNode
pub fn new(addr: &str) -> Self
Sourcepub fn register_agent(&self, agent_id: usize)
pub fn register_agent(&self, agent_id: usize)
Register a local agent so it can receive remote messages.
Sourcepub fn listen(&self)
pub fn listen(&self)
Start the TCP listener in a background thread. Incoming messages are dispatched to local agent mailboxes.
Sourcepub fn connect(&self, peer_addr: &str) -> Result<()>
pub fn connect(&self, peer_addr: &str) -> Result<()>
Connect to a peer node, storing the stream for future sends.
Sourcepub fn remote_send(
&self,
peer_addr: &str,
agent_id: usize,
trit: i8,
) -> Result<()>
pub fn remote_send( &self, peer_addr: &str, agent_id: usize, trit: i8, ) -> Result<()>
Send a trit to a remote agent’s mailbox.
Sourcepub fn remote_await(&self, peer_addr: &str, agent_id: usize) -> Result<i8>
pub fn remote_await(&self, peer_addr: &str, agent_id: usize) -> Result<i8>
Trigger a remote agent to process its mailbox and return the result trit.
Sourcepub fn local_send(&self, agent_id: usize, trit: i8)
pub fn local_send(&self, agent_id: usize, trit: i8)
Push a trit directly into a local agent’s mailbox (no network).
Trait Implementations§
Source§impl RemoteTransport for TernNode
Implement the VM’s RemoteTransport trait so TernNode can be injected
directly into BetVm::set_remote(Arc::new(node)).
impl RemoteTransport for TernNode
Implement the VM’s RemoteTransport trait so TernNode can be injected
directly into BetVm::set_remote(Arc::new(node)).
Auto Trait Implementations§
impl Freeze for TernNode
impl RefUnwindSafe for TernNode
impl Send for TernNode
impl Sync for TernNode
impl Unpin for TernNode
impl UnsafeUnpin for TernNode
impl UnwindSafe for TernNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more