Skip to content

Commit

Permalink
docs: improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofelletti committed Dec 10, 2024
1 parent 060beee commit 6c99aa2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/http/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ use core::fmt;
/// HTTP basic authorization type
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BasicAuthorization {
/// Provide ID and password. Calling `to_string` will return the encoded string,
/// Provide ID and password. Calling [`to_string`](Self::to_string) will return the encoded string,
/// or any other method relying on the `Display` trait
IdPassword(String, String),
/// Provide the already encoded string "ID:Password"
Encoded(String),
}

impl BasicAuthorization {
/// Create a new basic authorization using ID and password.
///
/// In particular, it returns a [`BasicAuthorization::IdPassword`] variant
/// of the [`BasicAuthorization`] enum.
#[must_use]
pub fn new(id: &str, password: &str) -> Self {
BasicAuthorization::IdPassword(id.to_owned(), password.to_owned())
}

/// Create a new basic authorization using the already encoded string
///
/// In particular, it returns a [`BasicAuthorization::Encoded`] variant
/// of the [`BasicAuthorization`] enum.
#[must_use]
pub fn new_encoded(encoded: &str) -> Self {
BasicAuthorization::Encoded(encoded.to_owned())
}
Expand Down

0 comments on commit 6c99aa2

Please sign in to comment.