urlshortener/
lib.rs

1//! # urlshortener
2//!
3//! An easy library for retrieving short urls.
4//!
5//! ## Usage
6//!
7//! Creating a short URL via a specified provider is very simple:
8//!
9//! ```rust,no_run
10//! use urlshortener::{providers::Provider, client::UrlShortener};
11//!
12//! let us = UrlShortener::new().unwrap();
13//! let short_url = us.generate("https://my-long-url.com", &Provider::IsGd);
14//! assert!(short_url.is_ok());
15//! ```
16//!
17//! Or attempting all URL shorteners until one is successfully generated:
18//!
19//! ```rust,no_run
20//! use urlshortener::client::UrlShortener;
21//!
22//! let us = UrlShortener::new().unwrap();
23//! let short_url = us.try_generate("https://my-long-url.com", None);
24//! assert!(short_url.is_ok());
25//! ```
26//! In order to use service with authentication use the appropriate provider directly:
27//!
28//! ```rust,no_run
29//! use urlshortener::{ client::UrlShortener, providers::Provider };
30//!
31//! let us = UrlShortener::new().unwrap();
32//! let key = "MY_API_KEY";
33//! let short_url = us.generate("https://my-long-url.com", &Provider::GooGl { api_key:
34//! key.to_owned() });
35//! assert!(short_url.is_ok());
36//! ```
37#![deny(missing_docs)]
38#![deny(warnings)]
39
40/// A urlshortener http client for performing requests.
41#[cfg(feature = "client")]
42pub mod client;
43pub mod providers;
44/// A request builders for sending via http client.
45pub mod request;
46
47/// A prelude module with main useful stuff.
48pub mod prelude {
49    #[cfg(feature = "client")]
50    pub use crate::client::*;
51    pub use crate::providers::{Provider, PROVIDERS};
52}