Struct linebased::Server[][src]

pub struct Server { /* fields omitted */ }

The linebased TCP server

Implementations

impl Server[src]

pub fn new<F>(config: Config, func: F) -> Result<Server> where
    F: Fn(&str) -> String + 'static + Send + Sync
[src]

Create a new server

use linebased::Server;

// Create a server with the default config and a
// handler that only knows the "version" command
let mut server = Server::new(Default::default(), |query| {
    match query {
        "version" => {
            String::from("0.1.0")
        },
        _ => {
            String::from("unknown command")
        }
    }
}).unwrap();

pub fn handle(&self) -> Handle[src]

Get a handle for the server so graceful shutdown can be requested

pub async fn run(&mut self) -> Result<()>[src]

Run the event loop

Auto Trait Implementations

impl !RefUnwindSafe for Server

impl Send for Server

impl Sync for Server

impl Unpin for Server

impl !UnwindSafe for Server

Blanket Implementations

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

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

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

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

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

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.

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.