pub struct UrlShortenerClient { /* private fields */ }Expand description
A client for the URL shortener API.
This client can be used in both async and blocking modes, depending on the feature flags.
§Example usage:
use spoo_me::client::UrlShortenerClient;
use spoo_me::requests::ShortenRequest;
use spoo_me::errors::UrlShortenerError;
#[tokio::main]
async fn main() -> Result<(), UrlShortenerError> {
let client = UrlShortenerClient::new();
let request = ShortenRequest::new("https://example.com/long/url")
.password("Example@123")
.max_clicks(100)
.block_bots(true);
let response = client.shorten(request).await?;
println!("Shortened URL: {}", response.short_url);
Ok(())
}Implementations§
Source§impl UrlShortenerClient
impl UrlShortenerClient
Sourcepub async fn shorten(
&self,
req: ShortenRequest,
) -> Result<ShortenResponse, UrlShortenerError>
pub async fn shorten( &self, req: ShortenRequest, ) -> Result<ShortenResponse, UrlShortenerError>
Shorten a URL (async mode).
Sourcepub async fn emoji(
&self,
req: EmojiRequest,
) -> Result<EmojiResponse, UrlShortenerError>
pub async fn emoji( &self, req: EmojiRequest, ) -> Result<EmojiResponse, UrlShortenerError>
Create an emoji URL (async mode).
Sourcepub async fn stats(
&self,
req: StatsRequest,
) -> Result<StatsResponse, UrlShortenerError>
pub async fn stats( &self, req: StatsRequest, ) -> Result<StatsResponse, UrlShortenerError>
Get statistics for a shortened URL (async mode).
Sourcepub async fn export(
&self,
req: ExportRequest,
) -> Result<ExportResponse, UrlShortenerError>
pub async fn export( &self, req: ExportRequest, ) -> Result<ExportResponse, UrlShortenerError>
Export data for a shortened URL (async mode).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UrlShortenerClient
impl !RefUnwindSafe for UrlShortenerClient
impl Send for UrlShortenerClient
impl Sync for UrlShortenerClient
impl Unpin for UrlShortenerClient
impl UnsafeUnpin for UrlShortenerClient
impl !UnwindSafe for UrlShortenerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more