From fe09f6f6fae3f9a4f8521b9333aea74b8a75bdca Mon Sep 17 00:00:00 2001 From: William Batista Date: Thu, 18 Feb 2021 12:58:05 -0500 Subject: [PATCH] v1.2.1 I forgot to add the new documentation to the README --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43390d7..1f6f49c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Build Status](https://www.travis-ci.com/billyb2/parse-magnet-rs.svg?branch=main)](https://www.travis-ci.com/billyb2/parse-magnet-rs) # What is a magnet url A magnet is a URI scheme that identifies files by their hash, normally used in peer to peer file sharing networks (like @@ -76,6 +75,33 @@ parameters! }; ``` +From a Magnet struct, you can generate a magnet string again + + ``` + use magnet_url::Magnet; + //Note, this magnet won't actually download, sorry :/ + let magnet_struct = Magnet { + dn: "hello_world".to_string(), + hash_type: "sha1".to_string(), + xt: "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed".to_string(), + xl: 1234567890, + tr: + { + let mut tr_vec = Vec::new(); + tr_vec.push("https://example.com/".to_string()); + tr_vec + }, + kt: "cool+stuff".to_string(), + ws: String::new(), + acceptable_source: String::new(), + mt: String::new(), + xs: String::new(), + }; + + let magnet_string = magnet_struct.to_string(); + println!("{}", magnet_string); + ``` + Invalid magnet url's will result in a panic! (This will be changed to an error in v2.0.0 ```#[should_panic] use magnet_url::Magnet;