Struct linebased::Server
[−]
[src]
pub struct Server {
// some fields omitted
}The linebased TCP server
Methods
impl Server[src]
fn new<F>(config: Config, func: F) -> Result<Server> where F: Fn(&str) -> String + 'static + Send
Create a new server
Examples
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();
fn handle(&self) -> Handle
Get a handle for the server so graceful shutdown can be requested
fn run(&mut self) -> Result<()>
Run the event loop
Blocks until a graceful shutdown is initiated or an unrecoverable error occurs.