1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
//! # urlshortener //! //! An easy library for retrieving short urls. //! //! ## Installation //! //! Add the following dependency to your project's `Cargo.toml`: //! //! ```toml //! [dependencies] //! urlshortener = "0.9" //! ``` //! //! And add this to your root file: //! //! ```no_run //! extern crate urlshortener; //! ``` //! //! ## Usage //! //! Creating a short URL via a specified provider is very simple: //! //! ```no_run //! use urlshortener::{providers::Provider, client::UrlShortener}; //! //! let us = UrlShortener::new().unwrap(); //! let short_url = us.generate("https://my-long-url.com", &Provider::IsGd); //! assert!(short_url.is_ok()); //! ``` //! //! Or attempting all URL shorteners until one is successfully generated: //! //! ```no_run //! use urlshortener::client::UrlShortener; //! //! let us = UrlShortener::new().unwrap(); //! let short_url = us.try_generate("https://my-long-url.com", None); //! assert!(short_url.is_ok()); //! ``` //! In order to use service with authentication use the appropriate provider directly: //! //! ```no_run //! use urlshortener::{ client::UrlShortener, providers::Provider }; //! //! let us = UrlShortener::new().unwrap(); //! let key = "MY_API_KEY"; //! let short_url = us.generate("https://my-long-url.com", &Provider::GooGl { api_key: //! key.to_owned() }); //! assert!(short_url.is_ok()); //! ``` #[deny(missing_docs)] #[cfg(feature = "client")] #[macro_use] extern crate log; #[cfg(feature = "client")] extern crate reqwest; extern crate url; /// A urlshortener http client for performing requests. #[cfg(feature = "client")] pub mod client; pub mod providers; /// A request builders for sending via http client. pub mod request; /// A prelude module with main useful stuff. pub mod prelude { #[cfg(feature = "client")] pub use client::*; pub use providers::{Provider, PROVIDERS}; }