Struct ckb_network::ServiceControl
source · [−]pub struct ServiceControl { /* private fields */ }Expand description
Service control, used to send commands externally at runtime
Implementations
sourceimpl ServiceControl
impl ServiceControl
sourcepub fn protocols(&self) -> &Arc<HashMap<ProtocolId, ProtocolInfo, RandomState>>
pub fn protocols(&self) -> &Arc<HashMap<ProtocolId, ProtocolInfo, RandomState>>
Get service protocol message, Map(ID, Name), but can’t modify
sourcepub fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
pub fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>
Create a new listener
sourcepub fn dial(
&self,
address: Multiaddr,
target: TargetProtocol
) -> Result<(), SendErrorKind>
pub fn dial(
&self,
address: Multiaddr,
target: TargetProtocol
) -> Result<(), SendErrorKind>
Initiate a connection request to address
sourcepub fn disconnect(&self, session_id: SessionId) -> Result<(), SendErrorKind>
pub fn disconnect(&self, session_id: SessionId) -> Result<(), SendErrorKind>
Disconnect a connection
sourcepub fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send message
sourcepub fn quick_send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn quick_send_message_to(
&self,
session_id: SessionId,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send message on quick channel
sourcepub fn filter_broadcast(
&self,
target: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn filter_broadcast(
&self,
target: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send data to the specified protocol for the specified sessions.
sourcepub fn quick_filter_broadcast(
&self,
target: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
pub fn quick_filter_broadcast(
&self,
target: TargetSession,
proto_id: ProtocolId,
data: Bytes
) -> Result<(), SendErrorKind>
Send data to the specified protocol for the specified sessions on quick channel.
sourcepub fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind> where
T: 'static + Future<Output = ()> + Send,
pub fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind> where
T: 'static + Future<Output = ()> + Send,
Send a future task
sourcepub fn open_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
pub fn open_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
Try open a protocol
If the protocol has been open, do nothing
sourcepub fn open_protocols(
&self,
session_id: SessionId,
target: TargetProtocol
) -> Result<(), SendErrorKind>
pub fn open_protocols(
&self,
session_id: SessionId,
target: TargetProtocol
) -> Result<(), SendErrorKind>
Try open protocol
If the protocol has been open, do nothing
sourcepub fn close_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
pub fn close_protocol(
&self,
session_id: SessionId,
proto_id: ProtocolId
) -> Result<(), SendErrorKind>
Try close a protocol
If the protocol has been closed, do nothing
sourcepub fn set_service_notify(
&self,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
pub fn set_service_notify(
&self,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
Set a service notify token
sourcepub fn remove_service_notify(
&self,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
pub fn remove_service_notify(
&self,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
remove a service notify token
sourcepub fn set_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
pub fn set_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
interval: Duration,
token: u64
) -> Result<(), SendErrorKind>
Set a session notify token
sourcepub fn remove_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
pub fn remove_session_notify(
&self,
session_id: SessionId,
proto_id: ProtocolId,
token: u64
) -> Result<(), SendErrorKind>
Remove a session notify token
sourcepub fn close(&self) -> Result<(), SendErrorKind>
pub fn close(&self) -> Result<(), SendErrorKind>
Close service
Order:
- close all listens
- try close all session’s protocol stream
- try close all session
- close service
sourcepub fn shutdown(&self) -> Result<(), SendErrorKind>
pub fn shutdown(&self) -> Result<(), SendErrorKind>
Shutdown service, don’t care anything, may cause partial message loss
Trait Implementations
sourceimpl Clone for ServiceControl
impl Clone for ServiceControl
sourcefn clone(&self) -> ServiceControl
fn clone(&self) -> ServiceControl
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl From<ServiceAsyncControl> for ServiceControl
impl From<ServiceAsyncControl> for ServiceControl
sourcefn from(control: ServiceAsyncControl) -> ServiceControl
fn from(control: ServiceAsyncControl) -> ServiceControl
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for ServiceControl
impl Send for ServiceControl
impl Sync for ServiceControl
impl Unpin for ServiceControl
impl !UnwindSafe for ServiceControl
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more