Struct apollo_framework::server::Server[][src]

pub struct Server<P: Default + Send + Sync> { /* fields omitted */ }

Represents a TODO server which manages all TCP connections.

Implementations

impl<P: 'static + Default + Send + Sync + Clone> Server<P>[src]

pub fn install(platform: &Arc<Platform>) -> Arc<Self>[src]

Creates and installs a Server into the given Platform.

Note that this is called by the Builder unless disabled.

Also note, that this will not technically start the server. This has to be done manually via event_loop as it is most probable done in the main thread.

pub fn connections(&self) -> Vec<ConnectionInfo<P>>[src]

Lists all currently active connections.

pub fn kill(&self, peer_address: &str) -> bool[src]

Kills the connection of the given peer address.

pub fn fork<F>(
    server: &Arc<Server<P>>,
    client_loop: &'static impl Fn(Arc<Platform>, Arc<Connection<P>>, TcpStream) -> F + Send + Sync
) where
    F: Future<Output = Result<()>> + Send + Sync
[src]

Starts the event loop in a separate thread.

This is most probably used by test scenarios where the tests itself run in the main thread.

pub async fn fork_and_await<F>(
    server: &Arc<Server<P>>,
    client_loop: &'static impl Fn(Arc<Platform>, Arc<Connection<P>>, TcpStream) -> F + Send + Sync
) where
    F: Future<Output = Result<()>> + Send + Sync
[src]

Starts the event loop in a separate thread and waits until the server is up and running.

Just like fork this is intended to be used in test environments.

pub async fn event_loop<F>(
    &self,
    client_loop: &'static impl Fn(Arc<Platform>, Arc<Connection<P>>, TcpStream) -> F + Send + Sync
) where
    F: Future<Output = Result<()>> + Send + Sync
[src]

Tries to open a server socket on the specified address to serve incoming client connections.

The task of this loop is to bind the server socket to the specified address. Once this was successful, we enter the server_loop to actually handle incoming connections. Once this loop returns, either the platform is no longer running and we should exit, or the config has changed and we should try to bind the server to the new address.

Auto Trait Implementations

impl<P> RefUnwindSafe for Server<P>

impl<P> Send for Server<P>

impl<P> Sync for Server<P>

impl<P> Unpin for Server<P>

impl<P> UnwindSafe for Server<P>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.