File: README.md

package info (click to toggle)
rust-data-url 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 244 kB
  • sloc: python: 11; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# data-url

[![crates.io](https://img.shields.io/crates/v/data-url.svg)](https://crates.io/crates/data-url)
[![docs.rs](https://img.shields.io/badge/docs.rs-%F0%9F%93%84-blue.svg)](https://docs.rs/data-url/)

Processing of `data:` URLs in Rust according to the Fetch Standard:
<https://fetch.spec.whatwg.org/#data-urls>
but starting from a string rather than a parsed URL to avoid extra copies.

```rust
use data_url::{DataUrl, mime};

let url = DataUrl::process("data:,Hello%20World!").unwrap();
let (body, fragment) = url.decode_to_vec().unwrap();

assert!(url.mime_type().is("text", "plain"));
assert_eq!(url.mime_type().get_parameter("charset"), Some("US-ASCII"));
assert_eq!(body, b"Hello World!");
assert!(fragment.is_none());
```