refactor attachment

This commit is contained in:
John Smith
2022-12-26 16:33:48 -05:00
parent 525baea32c
commit f49e4f0892
11 changed files with 402 additions and 239 deletions
+8 -8
View File
@@ -139,20 +139,20 @@ impl VeilidAPI {
#[instrument(level = "debug", err, skip_all)]
pub async fn attach(&self) -> Result<(), VeilidAPIError> {
let attachment_manager = self.attachment_manager()?;
attachment_manager
.request_attach()
.await
.map_err(|e| VeilidAPIError::internal(e))
if !attachment_manager.attach().await {
apibail_generic!("Already attached");
}
Ok(())
}
// disconnect from the network
#[instrument(level = "debug", err, skip_all)]
pub async fn detach(&self) -> Result<(), VeilidAPIError> {
let attachment_manager = self.attachment_manager()?;
attachment_manager
.request_detach()
.await
.map_err(|e| VeilidAPIError::internal(e))
if !attachment_manager.detach().await {
apibail_generic!("Already detached");
}
Ok(())
}
////////////////////////////////////////////////////////////////