pub struct ServiceControl { /* private fields */ }
Expand description

Service control, used to send commands externally at runtime

Implementations§

source§

impl ServiceControl

source

pub fn protocols(&self) -> &Arc<HashMap<ProtocolId, ProtocolInfo>>

Get service protocol message, Map(ID, Name), but can’t modify

source

pub fn listen(&self, address: Multiaddr) -> Result<(), SendErrorKind>

Create a new listener

source

pub fn dial( &self, address: Multiaddr, target: TargetProtocol ) -> Result<(), SendErrorKind>

Initiate a connection request to address

source

pub fn disconnect(&self, session_id: SessionId) -> Result<(), SendErrorKind>

Disconnect a connection

source

pub fn send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Send message

source

pub fn quick_send_message_to( &self, session_id: SessionId, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Send message on quick channel

source

pub fn filter_broadcast( &self, target: TargetSession, proto_id: ProtocolId, data: Bytes ) -> Result<(), SendErrorKind>

Send data to the specified protocol for the specified sessions.

source

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.

source

pub fn future_task<T>(&self, task: T) -> Result<(), SendErrorKind>
where T: Future<Output = ()> + 'static + Send,

Send a future task

source

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

source

pub fn open_protocols( &self, session_id: SessionId, target: TargetProtocol ) -> Result<(), SendErrorKind>

Try open protocol

If the protocol has been open, do nothing

source

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

source

pub fn set_service_notify( &self, proto_id: ProtocolId, interval: Duration, token: u64 ) -> Result<(), SendErrorKind>

Set a service notify token

source

pub fn remove_service_notify( &self, proto_id: ProtocolId, token: u64 ) -> Result<(), SendErrorKind>

remove a service notify token

source

pub fn set_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, interval: Duration, token: u64 ) -> Result<(), SendErrorKind>

Set a session notify token

source

pub fn remove_session_notify( &self, session_id: SessionId, proto_id: ProtocolId, token: u64 ) -> Result<(), SendErrorKind>

Remove a session notify token

source

pub fn close(&self) -> Result<(), SendErrorKind>

Close service

Order:

  1. close all listens
  2. try close all session’s protocol stream
  3. try close all session
  4. close service
source

pub fn shutdown(&self) -> Result<(), SendErrorKind>

Shutdown service, don’t care anything, may cause partial message loss

Trait Implementations§

source§

impl Clone for ServiceControl

source§

fn clone(&self) -> ServiceControl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<ServiceAsyncControl> for ServiceControl

source§

fn from(control: ServiceAsyncControl) -> ServiceControl

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more