-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "express-relay-simple-searcher" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
express-relay-client = { path = ".." } | ||
anyhow = { workspace = true } |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use { | ||
anyhow::{ | ||
anyhow, | ||
Result, | ||
}, | ||
express_relay_client::Client, | ||
}; | ||
|
||
fn main() -> Result<()> { | ||
let client = Client::try_new("http://127.0.0.1:9000", Some("test")).map_err(|e| { | ||
eprintln!("Failed to create client: {:?}", e); | ||
anyhow!("Failed to create client") | ||
})?; | ||
client.test(); | ||
Ok(()) | ||
} |
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,15 +1,24 @@ | ||
use url::Url; | ||
|
||
pub struct Client { | ||
pub host: String, | ||
pub host: Url, | ||
pub api_key: Option<String>, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum ClientError { | ||
InvalidHost(String), | ||
} | ||
|
||
impl Client { | ||
pub fn new(host: &str) -> Self { | ||
Self { | ||
host: host.to_string(), | ||
} | ||
pub fn try_new(host: &str, api_key: Option<&str>) -> Result<Self, ClientError> { | ||
Ok(Self { | ||
host: Url::parse(host).map_err(|e| ClientError::InvalidHost(e.to_string()))?, | ||
api_key: api_key.map(|s| s.to_string()), | ||
}) | ||
} | ||
|
||
pub fn test() { | ||
println!("test"); | ||
pub fn test(&self) { | ||
println!("Testing client with host: {:?}", self.host); | ||
} | ||
} |