Skip to content

Commit

Permalink
Fix rust-lang-nursery#722 (Broken Links)
Browse files Browse the repository at this point in the history
- CONTRIBUTING.md (removed link as its not required and no longer available)
- src/encoding/string/url-encode.md (updated form_urlencoded is not a part of url its re-exported)
- README.md (removed travis CI link [404](https://www.travis-ci.com/rust-lang-nursery/rust-cookbook))
- src/development_tools/debugging/config_log/log-custom.md (log4rs::config::Config is a re-export from log4rs::config::runtime::Config)
- src/web/scraping/broken.md (tokio::spawn to tokio::task::spawn)
- src/web/clients/api/rate-limited.md (removed file rust src broken links broken and is not used or displayed on the current cookbook build)
- src/cryptography/hashing/hmac.md (updated description, added tag type hint, and updated links)
  • Loading branch information
Arteiii committed Jan 9, 2025
1 parent 871258c commit 8bf7e96
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 81 deletions.
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,11 @@ after the code sample.
> generator [`rand::Rng`].
>
> The [distributions available are documented here][rand-distributions].
> An example using the [`Normal`] distribution is shown below.
[uniform distribution]: https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
[`Distribution::sample`]: https://docs.rs/rand/*/rand/distributions/trait.Distribution.html#tymethod.sample
[`rand::Rng`]: https://docs.rs/rand/*/rand/trait.Rng.html
[rand-distributions]: https://docs.rs/rand/*/rand/distributions/index.html
[`Normal`]: https://docs.rs/rand/*/rand/distributions/struct.Normal.html

#### Code

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# A Rust Cookbook   [![Build Status travis]][travis]

[Build Status travis]: https://api.travis-ci.com/rust-lang-nursery/rust-cookbook.svg?branch=master
[travis]: https://travis-ci.com/rust-lang-nursery/rust-cookbook

**[Read it here]**.

Expand Down
16 changes: 11 additions & 5 deletions src/cryptography/hashing/hmac.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

[![ring-badge]][ring] [![cat-cryptography-badge]][cat-cryptography]

Uses [`ring::hmac`] to creates a [`hmac::Signature`] of a string then verifies the signature is correct.

The [`hmac::sign`] method is used to calculate the HMAC digest (also called a tag) of the message using the provided key.
The resulting [`hmac::Tag`] structure contains the raw bytes of the HMAC,
which can later be verified with[`hmac::verify`] to ensure the message has not been tampered with and comes from a trusted source.

```rust,edition2018
use ring::{hmac, rand};
Expand All @@ -17,12 +18,17 @@ fn main() -> Result<(), Unspecified> {
let key = hmac::Key::new(hmac::HMAC_SHA256, &key_value);
let message = "Legitimate and important message.";
let signature = hmac::sign(&key, message.as_bytes());
let signature: hmac::Tag = hmac::sign(&key, message.as_bytes());
hmac::verify(&key, message.as_bytes(), signature.as_ref())?;
Ok(())
}
```

[`hmac::Signature`]: https://briansmith.org/rustdoc/ring/hmac/struct.Signature.html
[`ring::hmac`]: https://briansmith.org/rustdoc/ring/hmac/
[`ring::hmac`]: https://docs.rs/ring/*/ring/hmac/index.html

[`hmac::sign`]: https://docs.rs/ring/*/ring/hmac/fn.sign.html

[`hmac::Tag`]: https://docs.rs/ring/*/ring/hmac/struct.Tag.html

[`hmac::verify`]: https://docs.rs/ring/*/ring/hmac/fn.verify.html
2 changes: 1 addition & 1 deletion src/development_tools/debugging/config_log/log-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ fn main() -> Result<()> {
```

[`log4rs::append::file::FileAppender`]: https://docs.rs/log4rs/*/log4rs/append/file/struct.FileAppender.html
[`log4rs::config::Config`]: https://docs.rs/log4rs/*/log4rs/config/struct.Config.html
[`log4rs::config::Config`]: https://docs.rs/log4rs/*/log4rs/config/runtime/struct.Config.html
[`log4rs::encode::pattern`]: https://docs.rs/log4rs/*/log4rs/encode/pattern/index.html
[`log::LevelFilter`]: https://docs.rs/log/*/log/enum.LevelFilter.html
4 changes: 2 additions & 2 deletions src/encoding/string/url-encode.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
}
```

[`form_urlencoded::byte_serialize`]: https://docs.rs/url/*/url/form_urlencoded/fn.byte_serialize.html
[`form_urlencoded::parse`]: https://docs.rs/url/*/url/form_urlencoded/fn.parse.html
[`form_urlencoded::byte_serialize`]: https://docs.rs//fn.byte_serialize.html
[`form_urlencoded::parse`]: https://docs.rs/form_urlencoded/*/form_urlencoded/fn.parse.html

[application/x-www-form-urlencoded]: https://url.spec.whatwg.org/#application/x-www-form-urlencoded
68 changes: 0 additions & 68 deletions src/web/clients/api/rate-limited.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/web/scraping/broken.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Call `get_base_url` to retrieve the base URL. If the document has a base tag,
get the href [`attr`] from base tag. [`Position::BeforePath`] of the original
URL acts as a default.

Iterates through links in the document and creates a [`tokio::spawn`] task that will
Iterates through links in the document and creates a [`tokio::task::spawn`] task that will
parse an individual link with [`url::ParseOptions`] and [`Url::parse`]).
The task makes a request to the links with [reqwest] and verifies
[`StatusCode`]. Then the tasks `await` completion before ending the program.
Expand All @@ -28,6 +28,6 @@ fn main() -> anyhow::Result<()> {
[`attr`]: https://docs.rs/select/*/select/node/struct.Node.html#method.attr
[`Position::BeforePath`]: https://docs.rs/url/*/url/enum.Position.html#variant.BeforePath
[`StatusCode`]: https://docs.rs/reqwest/*/reqwest/struct.StatusCode.html
[`tokio::spawn`]: https://docs.rs/tokio/*/tokio/fn.spawn.html
[`tokio::task::spawn`]: https://docs.rs/tokio/*/tokio/task/fn.spawn.html
[`url::Parse`]: https://docs.rs/url/*/url/struct.Url.html#method.parse
[`url::ParseOptions`]: https://docs.rs/url/*/url/struct.ParseOptions.html

0 comments on commit 8bf7e96

Please sign in to comment.