Restructure project and add examples.

This commit is contained in:
FireMasterK 2021-04-29 20:56:18 +05:30
parent b780f05f0c
commit 9f2ccc35ee
No known key found for this signature in database
GPG Key ID: 8DFF5DD33E93DB58
5 changed files with 56 additions and 12 deletions

View File

@ -1,12 +1,5 @@
[package]
authors = ["Kavin <kavin@kavin.rocks>"]
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",
]

14
examples/Cargo.toml Normal file
View File

@ -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"

21
examples/channel.rs Normal file
View File

@ -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);
}

16
piped/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
authors = ["Kavin <kavin@kavin.rocks>"]
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"