oembed 0.1.0

Simple generic implementation of oEmbed 1.0
Documentation
  • Coverage
  • 44.64%
    25 out of 56 items documented1 out of 17 items with examples
  • Size
  • Source code size: 139.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.03 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • flisk/oembed-rs
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Flisk

oembed-rs

A generic implementation of oEmbed 1.0.

Latest Version Documentation License

Currently Unsupported

  • Endpoint discovery
  • XML responses

Quick Start

use std::error::Error;
use std::borrow::Cow;
use oembed::client::*;

struct DummyHttp;

impl Http for DummyHttp {
    fn url_encode<'a>(&mut self, s: &'a str) -> HttpResult<Cow<'a, str>> {
        Ok(s.into())
    }

    fn get(&mut self, _url: &str) -> HttpResult<String> {
        Ok("{
            \"version\": \"1.0\",
            \"type\": \"photo\",
            \"width\": 240,
            \"height\": 160,
            \"title\": \"ZB8T0193\",
            \"url\": \"http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg\",
            \"author_name\": \"Bees\",
            \"author_url\": \"http://www.flickr.com/photos/bees/\",
            \"provider_name\": \"Flickr\",
            \"provider_url\": \"http://www.flickr.com/\"
        }".to_string())
    }
}

let schema = Schema::load_included();
let some_url = "http://www.flickr.com/photos/bees/2341623661/";
let mut http = DummyHttp {};

let response = schema.fetch(&mut http, some_url)
    .expect("Missing provider")
    .expect("Failed to fetch server response");

println!("{:?}", response);

License

The oembed-rs crate is under the MIT license, which is included in LICENSE.txt.

The included provider list (src/providers.json) is under the MIT license, which is included in LICENSE.providers.txt.