-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use async_trait in the network Adapter trait
- Loading branch information
Showing
4 changed files
with
37 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
use crate::network::NetworkState; | ||
use async_trait::async_trait; | ||
use std::error::Error; | ||
|
||
/// A trait for the ability to read/write from/to a network service | ||
#[async_trait] | ||
pub trait Adapter { | ||
fn read(&self) -> Result<NetworkState, Box<dyn Error>>; | ||
fn write(&self, network: &NetworkState) -> Result<(), Box<dyn Error>>; | ||
async fn read(&self) -> Result<NetworkState, Box<dyn Error>>; | ||
async fn write(&self, network: &NetworkState) -> Result<(), Box<dyn Error>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters