pub struct WebService { /* private fields */ }Expand description
Manageable web service with start/stop lifecycle
Use this when you need to programmatically control the server lifecycle, such as in tests or embedded scenarios.
Implementations§
Source§impl WebService
impl WebService
Sourcepub fn new(bamboo_home_dir: PathBuf) -> Self
pub fn new(bamboo_home_dir: PathBuf) -> Self
Create a new WebService instance
§Arguments
bamboo_home_dir- Bamboo home directory (e.g.,${HOME}/.bambooor custom path)
Sourcepub async fn start(&mut self, port: u16) -> Result<(), String>
pub async fn start(&mut self, port: u16) -> Result<(), String>
Start the web service on the specified port using the default localhost bind.
Sourcepub async fn start_with_bind(
&mut self,
port: u16,
bind: &str,
) -> Result<(), String>
pub async fn start_with_bind( &mut self, port: u16, bind: &str, ) -> Result<(), String>
Start the web service on the specified port and bind address.
Sourcepub async fn start_with_bind_and_static(
&mut self,
port: u16,
bind: &str,
static_dir: PathBuf,
) -> Result<(), String>
pub async fn start_with_bind_and_static( &mut self, port: u16, bind: &str, static_dir: PathBuf, ) -> Result<(), String>
Start the web service on the specified port and bind address, serving static files alongside the API routes.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the web service is currently running
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebService
impl !RefUnwindSafe for WebService
impl Send for WebService
impl Sync for WebService
impl Unpin for WebService
impl UnsafeUnpin for WebService
impl !UnwindSafe for WebService
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