pub struct Listener<W: Watcher> { /* private fields */ }Implementations§
Source§impl<W: Watcher + Send + 'static> Listener<W>
impl<W: Watcher + Send + 'static> Listener<W>
Sourcepub async fn start(self, options: Options) -> Result<(), Box<dyn Error>>
pub async fn start(self, options: Options) -> Result<(), Box<dyn Error>>
Start live-server.
use live_server::{listen, Options};
async fn serve() -> Result<(), Box<dyn std::error::Error>> {
listen("127.0.0.1:8080", "./").await?.start(Options::default()).await
}Sourcepub fn link(&self) -> Result<String, Box<dyn Error>>
pub fn link(&self) -> Result<String, Box<dyn Error>>
Return the link of the server, like http://127.0.0.1:8080.
use live_server::{listen, Options};
async fn serve() {
let listener = listen("127.0.0.1:8080", "./").await.unwrap();
let link = listener.link().unwrap();
assert_eq!(link, "http://127.0.0.1:8080");
}This is useful when you did not specify the host or port (e.g. listen("0.0.0.0:0", ".")),
because this method will return the specific address.
Auto Trait Implementations§
impl<W> !Freeze for Listener<W>
impl<W> !RefUnwindSafe for Listener<W>
impl<W> Send for Listener<W>where
W: Send,
impl<W> Sync for Listener<W>where
W: Sync,
impl<W> Unpin for Listener<W>where
W: Unpin,
impl<W> !UnwindSafe for Listener<W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more