Skip to main content

CurrentLayer

Trait CurrentLayer 

Source
pub trait CurrentLayer {
    // Required methods
    fn export(&self, msg: &[u8]) -> Vec<u8> ;
    fn import(&self, data: &[u8]) -> Option<Vec<u8>>;
    fn transport_id(&self) -> String;
}
Expand description

Cross-runtime transport (git-based i2i).

Implements L3 Current → plato-bridge / plato-hooks (git-based inter-instance transport).

§Examples

use plato_ship_protocol::CurrentLayer;

struct MockCurrent;

impl CurrentLayer for MockCurrent {
    fn export(&self, msg: &[u8]) -> Vec<u8> {
        let mut out = b"git:".to_vec();
        out.extend_from_slice(msg);
        out
    }
    fn import(&self, data: &[u8]) -> Option<Vec<u8>> {
        data.strip_prefix(b"git:").map(|b| b.to_vec())
    }
    fn transport_id(&self) -> String { "git-i2i-mock".to_string() }
}

let c = MockCurrent;
let exported = c.export(b"payload");
assert_eq!(c.import(&exported), Some(b"payload".to_vec()));

Required Methods§

Source

fn export(&self, msg: &[u8]) -> Vec<u8>

Serialize and frame a message for cross-runtime export.

Source

fn import(&self, data: &[u8]) -> Option<Vec<u8>>

Deserialize and unframe an incoming cross-runtime message. Returns None if the frame is malformed.

Source

fn transport_id(&self) -> String

A stable identifier for this transport implementation.

Implementors§