I forgot to add the new documentation to the README
This commit is contained in:
William Batista 2021-02-18 12:58:05 -05:00
parent dbffe62a40
commit fe09f6f6fa
No known key found for this signature in database
GPG Key ID: C6D7973D216F38D3
1 changed files with 27 additions and 1 deletions

View File

@ -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;