pub trait SocketServiceExt: IsA<SocketService> + 'static {
// Provided methods
fn is_active(&self) -> bool { ... }
fn start(&self) { ... }
fn stop(&self) { ... }
fn set_active(&self, active: bool) { ... }
fn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_active_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
Sourcefn start(&self)
fn start(&self)
Restarts the service, i.e. start accepting connections from the added sockets when the mainloop runs. This only needs to be called after the service has been stopped from g_socket_service_stop().
This call is thread-safe, so it may be called from a thread handling an incoming client request.
Sourcefn stop(&self)
fn stop(&self)
Stops the service, i.e. stops accepting connections from the added sockets when the mainloop runs.
This call is thread-safe, so it may be called from a thread handling an incoming client request.
Note that this only stops accepting new connections; it does not close the listening sockets, and you can call g_socket_service_start() again later to begin listening again. To close the listening sockets, call g_socket_listener_close(). (This will happen automatically when the #GSocketService is finalized.)
This must be called before calling g_socket_listener_close() as the socket service will start accepting connections immediately when a new socket is added.
Sourcefn set_active(&self, active: bool)
fn set_active(&self, active: bool)
Whether the service is currently accepting connections.
Sourcefn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_incoming<F: Fn(&Self, &SocketConnection, Option<&Object>) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
The ::incoming signal is emitted when a new incoming connection to @service needs to be handled. The handler must initiate the handling of @connection, but may not block; in essence, asynchronous operations must be used.
@connection will be unreffed once the signal handler returns, so you need to ref it yourself if you are planning to use it.
§connection
a new #GSocketConnection object
§source_object
the source_object passed to g_socket_listener_add_address()
§Returns
true
to stop other handlers from being called
fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.