Trait ckb_network::CKBProtocolHandler[][src]

pub trait CKBProtocolHandler: Sync + Send {
    fn init(&mut self, nc: Arc<dyn CKBProtocolContext + Sync>);

    fn connected(
        &mut self,
        _nc: Arc<dyn CKBProtocolContext + Sync>,
        _peer_index: PeerIndex,
        _version: &str
    ) { ... }
fn disconnected(
        &mut self,
        _nc: Arc<dyn CKBProtocolContext + Sync>,
        _peer_index: PeerIndex
    ) { ... }
fn received(
        &mut self,
        _nc: Arc<dyn CKBProtocolContext + Sync>,
        _peer_index: PeerIndex,
        _data: Bytes
    ) { ... }
fn notify(&mut self, _nc: Arc<dyn CKBProtocolContext + Sync>, _token: u64) { ... }
fn poll(
        &mut self,
        _nc: Arc<dyn CKBProtocolContext + Sync>
    ) -> Poll<Option<()>> { ... } }
Expand description

Abstract protocol handle base on tentacle service handle

Required methods

fn init(&mut self, nc: Arc<dyn CKBProtocolContext + Sync>)[src]

Init action on service run

Provided methods

fn connected(
    &mut self,
    _nc: Arc<dyn CKBProtocolContext + Sync>,
    _peer_index: PeerIndex,
    _version: &str
)
[src]

Called when opening protocol

fn disconnected(
    &mut self,
    _nc: Arc<dyn CKBProtocolContext + Sync>,
    _peer_index: PeerIndex
)
[src]

Called when closing protocol

fn received(
    &mut self,
    _nc: Arc<dyn CKBProtocolContext + Sync>,
    _peer_index: PeerIndex,
    _data: Bytes
)
[src]

Called when the corresponding protocol message is received

fn notify(&mut self, _nc: Arc<dyn CKBProtocolContext + Sync>, _token: u64)[src]

Called when the Service receives the notify task

fn poll(&mut self, _nc: Arc<dyn CKBProtocolContext + Sync>) -> Poll<Option<()>>[src]

Behave like Stream::poll

Implementors