Przeglądaj źródła

Add metadata for the data-url crate

Simon Sapin 8 lat temu
rodzic
commit
a6e63fed24
4 zmienionych plików z 26 dodań i 0 usunięć
  1. 3 0
      data-url/Cargo.toml
  2. 1 0
      data-url/LICENSE-APACHE
  3. 1 0
      data-url/LICENSE-MIT
  4. 21 0
      data-url/README.md

+ 3 - 0
data-url/Cargo.toml

@@ -2,6 +2,9 @@
 name = "data-url"
 version = "0.1.0"
 authors = ["Simon Sapin <simon.sapin@exyr.org>"]
+description = "Processing of data: URL according to WHATWG’s Fetch Standard"
+repository = "https://github.com/servo/rust-url"
+license = "MIT OR Apache-2.0"
 
 [dependencies]
 matches = "0.1"

+ 1 - 0
data-url/LICENSE-APACHE

@@ -0,0 +1 @@
+../LICENSE-APACHE

+ 1 - 0
data-url/LICENSE-MIT

@@ -0,0 +1 @@
+../LICENSE-MIT

+ 21 - 0
data-url/README.md

@@ -0,0 +1,21 @@
+# data-url
+
+![crates.io](https://img.shields.io/crates/v/url.svg)
+![docs.rs](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_eq!(url.mime_type().type_, "text");
+assert_eq!(url.mime_type().subtype, "plain");
+assert_eq!(url.mime_type().get_parameter("charset"), Some("US-ASCII"));
+assert_eq!(body, b"Hello World!");
+assert!(fragment.is_none());
+```