Crate oembed_rs

Source
Expand description

§Documentation

This crate provides a simple interface for fetching oEmbed data from known providers.

§Example

use oembed_rs::{find_provider, fetch, ConsumerRequest};

async fn example() {
    let url = "https://twitter.com/user/status/1000000000000000000";
    let (_, endpoint) = find_provider(url).expect("unknown provider");

    let response = fetch(
       &endpoint.url,
       ConsumerRequest {
           url,
           max_width: Some(1000),
           max_height: Some(500),
           ..ConsumerRequest::default()
       },
    )
    .await
    .expect("failed to fetch oembed data");
}

Structs§

ConsumerRequest
Request for fetching oEmbed data
EmbedResponse
oEmbed response
Endpoint
An oEmbed provider endpoint
Photo
Photo type
Provider
An oEmbed provider
Rich
Rich type
Video
Video type

Enums§

EmbedType
Represents one of the oEmbed data types
Error

Functions§

fetch
Fetch oEmbed data from the endpoint of a provider
find_provider
Find the oEmbed provider and endpoint based on the URL
matches_scheme
Checks if the URL matches the scheme