Crates.io | dataurl |
lib.rs | dataurl |
version | 0.1.2 |
source | src |
created_at | 2021-10-18 07:04:46.312053 |
updated_at | 2021-10-30 08:47:04.100648 |
description | CLI tool and Rust crate for parsing and generating data URLs |
homepage | https://github.com/Y2Z/dataurl |
repository | https://github.com/Y2Z/dataurl |
max_upload_size | |
id | 466639 |
size | 30,781 |
CLI tool / Rust crate for converting files and text into data URLs and back
cargo install dataurl
docker build -t Y2Z/dataurl .
sudo install -b dist/run-in-container.sh /usr/local/bin/dataurl
git clone https://github.com/Y2Z/dataurl.git
cd dataurl
make install
Every release contains pre-built binaries for Windows, GNU/Linux, as well as platforms with non-standart CPU architecture.
dataurl "some text"
dataurl -d 'data:text/html,text<a id%3D"b">ok</a>?a=v#f' > index.html
dataurl -i picture.png
cat file.txt | dataurl -i -
cat file.png | dataurl
use dataurl::DataUrl;
let data_url: DataUrl = DataUrl::parse("data:,Hello,%20World!")?;
assert_eq!(data_url.get_media_type(), "text/plain".to_string());
assert_eq!(data_url.get_media_type_no_default(), None);
assert_eq!(data_url.get_charset(), "US-ASCII".to_string());
assert_eq!(data_url.get_charset_no_default(), None);
assert!(!data_url.get_is_base64_encoded());
assert_eq!(data_url.get_data(), [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]);
assert_eq!(data_url.get_fragment(), None);
assert_eq!(data_url.to_string(), "data:,Hello%2C%20World%21");
assert_eq!(data_url.get_text(), "Hello, World!");
-b
: Encode data using base64
-d
: Attempt to parse input, output resulting data
-c
: Use custom charset
-f
: Append fragment
-i
: Specify file
to read data from (use -
for STDIN)
-t
: Adjust media type
To the extent possible under law, the author(s) have dedicated all copyright related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.