From 9f2ccc35ee196400b06948dad708a040cdd796a4 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 29 Apr 2021 20:56:18 +0530 Subject: [PATCH] Restructure project and add examples. --- Cargo.toml | 17 +++++------------ examples/Cargo.toml | 14 ++++++++++++++ examples/channel.rs | 21 +++++++++++++++++++++ piped/Cargo.toml | 16 ++++++++++++++++ {src => piped/src}/lib.rs | 0 5 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 examples/Cargo.toml create mode 100644 examples/channel.rs create mode 100644 piped/Cargo.toml rename {src => piped/src}/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 5e58a27..02db0f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,5 @@ -[package] -authors = ["Kavin "] -edition = "2018" -name = "piped-rust-sdk" -version = "0.1.0" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -reqwest = "0.11.3" -serde = {version = "1.0.125", features = ["derive"]} -serde_json = "1.0.64" +[workspace] +members = [ + "piped", + "examples", +] diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000..8712f69 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,14 @@ +[package] +edition = "2018" +name = "examples" +publish = false +version = "0.0.0" + +[dev-dependencies] +piped = {path = "../piped"} +reqwest = "0.11.3" +tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]} + +[[example]] +name = "channel" +path = "channel.rs" diff --git a/examples/channel.rs b/examples/channel.rs new file mode 100644 index 0000000..91c75eb --- /dev/null +++ b/examples/channel.rs @@ -0,0 +1,21 @@ +use piped::piped::PipedClient; +use reqwest::ClientBuilder; + +#[tokio::main] +async fn main() { + let httpclient = ClientBuilder::new() + .user_agent("Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0") + .build() + .unwrap(); + + let instance = "https://pipedapi.kavin.rocks".to_string(); + + let client = PipedClient::new(httpclient, instance); + + let channel = client + .get_channel_from_id("UCXuqSBlHAE6Xw-yeJA0Tunw".to_string()) + .await + .unwrap(); + + println!("{:?}", channel); +} diff --git a/piped/Cargo.toml b/piped/Cargo.toml new file mode 100644 index 0000000..a0ef00d --- /dev/null +++ b/piped/Cargo.toml @@ -0,0 +1,16 @@ +[package] +authors = ["Kavin "] +edition = "2018" +include = [ + "src/*.rs", + "Cargo.toml", +] +name = "piped" +version = "0.1.0" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +reqwest = "0.11.3" +serde = {version = "1.0.125", features = ["derive"]} +serde_json = "1.0.64" diff --git a/src/lib.rs b/piped/src/lib.rs similarity index 100% rename from src/lib.rs rename to piped/src/lib.rs