diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-04-06 12:50:53 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-04-06 12:51:22 +0200 |
commit | c75c23cec594837bfede6341787f80216f42e0ae (patch) | |
tree | 38bff9fc959474a38ac1079c23f18596f471c795 | |
parent | 7d1806f7b09a8b610cfe2cce12795c444fbef8cb (diff) |
fixup! Restructure for use with reqwest
-rw-r--r-- | librepology/Cargo.toml | 2 | ||||
-rw-r--r-- | librepology/src/endpoint.rs | 12 | ||||
-rw-r--r-- | librepology/src/lib.rs | 1 | ||||
-rw-r--r-- | librepology/src/v1/api.rs | 14 | ||||
-rw-r--r-- | librepology/src/v1/endpoint.rs | 11 | ||||
-rw-r--r-- | librepology/src/v1/mod.rs | 2 |
6 files changed, 41 insertions, 1 deletions
diff --git a/librepology/Cargo.toml b/librepology/Cargo.toml index c82161c..9055052 100644 --- a/librepology/Cargo.toml +++ b/librepology/Cargo.toml @@ -16,7 +16,7 @@ license = "MPL-2.0" maintenance = { status = "actively-developed" } [dependencies] -1eqwest = "0.11" +reqwest = "0.11" serde = { version = "1", features = ["derive"] } serde_json = "1" thiserror = "1" diff --git a/librepology/src/endpoint.rs b/librepology/src/endpoint.rs new file mode 100644 index 0000000..8bc4fc5 --- /dev/null +++ b/librepology/src/endpoint.rs @@ -0,0 +1,12 @@ +pub trait EndpointUrl { + fn endpoint_url() -> &'static str; +} + +pub struct DefaultEndpoint(crate::v1::endpoint::V1ApiEndpoint); + +impl EndpointUrl for DefaultEndpoint { + #[inline] + fn endpoint_url() -> &'static str { + crate::v1::endpoint::V1ApiEndpoint::endpoint_url() + } +} diff --git a/librepology/src/lib.rs b/librepology/src/lib.rs index a3a6d96..83b8184 100644 --- a/librepology/src/lib.rs +++ b/librepology/src/lib.rs @@ -1 +1,2 @@ pub mod v1; +pub mod endpoint; diff --git a/librepology/src/v1/api.rs b/librepology/src/v1/api.rs new file mode 100644 index 0000000..1f9b076 --- /dev/null +++ b/librepology/src/v1/api.rs @@ -0,0 +1,14 @@ +use crate::endpoint::EndpointUrl; + +pub struct ApiClient { + endpoint_url: &'static str, +} + +impl ApiClient { + pub fn new<EP: EndpointUrl>() -> Self { + ApiClient { + endpoint_url: EP::endpoint_url(), + } + } + +} diff --git a/librepology/src/v1/endpoint.rs b/librepology/src/v1/endpoint.rs new file mode 100644 index 0000000..732691d --- /dev/null +++ b/librepology/src/v1/endpoint.rs @@ -0,0 +1,11 @@ +use crate::endpoint::EndpointUrl; + +pub struct V1ApiEndpoint; + +impl EndpointUrl for V1ApiEndpoint { + #[inline] + fn endpoint_url() -> &'static str { + "https://repology.org/api/v1/" + } +} + diff --git a/librepology/src/v1/mod.rs b/librepology/src/v1/mod.rs index 5c74364..ec13109 100644 --- a/librepology/src/v1/mod.rs +++ b/librepology/src/v1/mod.rs @@ -1,2 +1,4 @@ +pub mod api; +pub mod endpoint; pub mod error; pub mod types; |