Struct soundcloud::Client [] [src]

pub struct Client {
    // some fields omitted
}

Methods

impl Client
[src]

fn new(client_id: &str) -> Client

Constructs a new Client with the provided client_id.

Examples

use soundcloud::Client;

let client = Client::new(env!("SOUNDCLOUD_CLIENT_ID"));

fn client_id(&self) -> &str

Returns the client id.

fn get<I, K, V>(&self, path: &str, params: Option<I>) -> Result<ResponseError> where I: IntoIterator, I::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str>

Creates and sends a HTTP GET request to the API endpoint.

A client_id parameter will automatically be added to the request.

Returns the HTTP response on success, an error otherwise.

Examples

use std::io::Read;
use soundcloud::Client;
let client = Client::new(env!("SOUNDCLOUD_CLIENT_ID"));
let response = client.get("/resolve", Some(&[("url",
"https://soundcloud.com/firepowerrecs/afk-shellshock-kamikaze-promo-mix-lock-load-series-vol-20")]));

let mut buffer = String::new();
response.unwrap().read_to_string(&mut buffer);

assert!(!buffer.is_empty());

fn download<W: Write>(&self, track: &Track, writer: W) -> Result<usize>

fn stream<W: Write>(&self, track: &Track, writer: W) -> Result<usize>

Starts streaming the track provided in the tracks stream_url to the writer if the track is streamable via the API.

fn resolve(&self, url: &str) -> Result<Url>

Resolves any soundcloud resource and returns it as a Url.

fn track(&self, id: usize) -> SingleTrackRequestBuilder

Returns a builder for a single track-by-id request.

Examples

use soundcloud::Client;

let client = Client::new(env!("SOUNDCLOUD_CLIENT_ID"));
let track = client.track(262681089).get();

assert_eq!(track.unwrap().id, 262681089);

fn tracks(&self) -> TrackRequestBuilder

Returns a builder for searching tracks with multiple criteria.

Examples

use soundcloud::Client;

let client = Client::new(env!("SOUNDCLOUD_CLIENT_ID"));
let tracks = client.tracks().genres(Some(["HipHop"])).get();

assert!(tracks.unwrap().expect("no tracks found").len() > 0);

Trait Implementations

Derived Implementations

impl Debug for Client
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.