pub struct Listener { /* private fields */ }
Implementations§
Source§impl Listener
impl Listener
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 !Freeze for Listener
impl !RefUnwindSafe for Listener
impl Send for Listener
impl Sync for Listener
impl Unpin for Listener
impl !UnwindSafe for Listener
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