Crates.io | data-url |
lib.rs | data-url |
version | 0.3.2 |
created_at | 2018-02-02 09:20:35.995542+00 |
updated_at | 2025-08-21 08:45:42.636371+00 |
description | Processing of data: URL according to WHATWG’s Fetch Standard |
homepage | |
repository | https://github.com/servo/rust-url |
max_upload_size | |
id | 49319 |
size | 134,754 |
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.
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());