mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
sasl: make docs.rs emit nice feature tags on feature-gated items
This commit is contained in:
parent
1293e9a3eb
commit
13be111de1
9 changed files with 21 additions and 0 deletions
|
@ -26,3 +26,7 @@ sha-1 = { version = "0.10", optional = true }
|
||||||
sha2 = { version = "0.10", optional = true }
|
sha2 = { version = "0.10", optional = true }
|
||||||
hmac = { version = "0.12", optional = true }
|
hmac = { version = "0.12", optional = true }
|
||||||
pbkdf2 = { version = "0.12", default-features = false, optional = true }
|
pbkdf2 = { version = "0.12", default-features = false, optional = true }
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
|
@ -10,4 +10,5 @@ pub use self::anonymous::Anonymous;
|
||||||
pub use self::plain::Plain;
|
pub use self::plain::Plain;
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub use self::scram::Scram;
|
pub use self::scram::Scram;
|
||||||
|
|
|
@ -34,6 +34,7 @@ pub enum MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<DeriveError> for MechanismError {
|
impl From<DeriveError> for MechanismError {
|
||||||
fn from(err: DeriveError) -> MechanismError {
|
fn from(err: DeriveError) -> MechanismError {
|
||||||
MechanismError::DeriveError(err)
|
MechanismError::DeriveError(err)
|
||||||
|
@ -41,6 +42,7 @@ impl From<DeriveError> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<InvalidLength> for MechanismError {
|
impl From<InvalidLength> for MechanismError {
|
||||||
fn from(err: InvalidLength) -> MechanismError {
|
fn from(err: InvalidLength) -> MechanismError {
|
||||||
MechanismError::InvalidKeyLength(err)
|
MechanismError::InvalidKeyLength(err)
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub mod scram;
|
pub mod scram;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
|
|
@ -5,6 +5,7 @@ use getrandom::Error as RngError;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
/// An error while initializing the Rng.
|
/// An error while initializing the Rng.
|
||||||
RngError(RngError),
|
RngError(RngError),
|
||||||
/// An error in a SASL mechanism.
|
/// An error in a SASL mechanism.
|
||||||
|
@ -12,6 +13,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<RngError> for Error {
|
impl From<RngError> for Error {
|
||||||
fn from(err: RngError) -> Error {
|
fn from(err: RngError) -> Error {
|
||||||
Error::RngError(err)
|
Error::RngError(err)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
//#![deny(missing_docs)]
|
//#![deny(missing_docs)]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
//! This crate provides a framework for SASL authentication and a few authentication mechanisms.
|
//! This crate provides a framework for SASL authentication and a few authentication mechanisms.
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub struct Pbkdf2Sha1 {
|
||||||
|
|
||||||
impl Pbkdf2Sha1 {
|
impl Pbkdf2Sha1 {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub fn derive(password: &str, salt: &[u8], iterations: u32) -> Result<Pbkdf2Sha1, DeriveError> {
|
pub fn derive(password: &str, salt: &[u8], iterations: u32) -> Result<Pbkdf2Sha1, DeriveError> {
|
||||||
use crate::common::scram::{ScramProvider, Sha1};
|
use crate::common::scram::{ScramProvider, Sha1};
|
||||||
use crate::common::Password;
|
use crate::common::Password;
|
||||||
|
@ -58,6 +59,7 @@ pub struct Pbkdf2Sha256 {
|
||||||
|
|
||||||
impl Pbkdf2Sha256 {
|
impl Pbkdf2Sha256 {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub fn derive(
|
pub fn derive(
|
||||||
password: &str,
|
password: &str,
|
||||||
salt: &[u8],
|
salt: &[u8],
|
||||||
|
|
|
@ -5,7 +5,9 @@ mod plain;
|
||||||
mod scram;
|
mod scram;
|
||||||
|
|
||||||
#[cfg(feature = "anonymous")]
|
#[cfg(feature = "anonymous")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "anonymous")))]
|
||||||
pub use self::anonymous::Anonymous;
|
pub use self::anonymous::Anonymous;
|
||||||
pub use self::plain::Plain;
|
pub use self::plain::Plain;
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub use self::scram::Scram;
|
pub use self::scram::Scram;
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub trait Validator<S: Secret> {
|
||||||
pub enum ProviderError {
|
pub enum ProviderError {
|
||||||
AuthenticationFailed,
|
AuthenticationFailed,
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
DeriveError(DeriveError),
|
DeriveError(DeriveError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +66,10 @@ pub enum MechanismError {
|
||||||
|
|
||||||
CannotDecodeResponse,
|
CannotDecodeResponse,
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
InvalidKeyLength(hmac::digest::InvalidLength),
|
InvalidKeyLength(hmac::digest::InvalidLength),
|
||||||
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "scram", feature = "anonymous"))))]
|
||||||
RandomFailure(getrandom::Error),
|
RandomFailure(getrandom::Error),
|
||||||
NoProof,
|
NoProof,
|
||||||
CannotDecodeProof,
|
CannotDecodeProof,
|
||||||
|
@ -75,6 +78,7 @@ pub enum MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<DeriveError> for ProviderError {
|
impl From<DeriveError> for ProviderError {
|
||||||
fn from(err: DeriveError) -> ProviderError {
|
fn from(err: DeriveError) -> ProviderError {
|
||||||
ProviderError::DeriveError(err)
|
ProviderError::DeriveError(err)
|
||||||
|
@ -100,6 +104,7 @@ impl From<ValidatorError> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<hmac::digest::InvalidLength> for MechanismError {
|
impl From<hmac::digest::InvalidLength> for MechanismError {
|
||||||
fn from(err: hmac::digest::InvalidLength) -> MechanismError {
|
fn from(err: hmac::digest::InvalidLength) -> MechanismError {
|
||||||
MechanismError::InvalidKeyLength(err)
|
MechanismError::InvalidKeyLength(err)
|
||||||
|
@ -107,6 +112,7 @@ impl From<hmac::digest::InvalidLength> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "scram", feature = "anonymous"))))]
|
||||||
impl From<getrandom::Error> for MechanismError {
|
impl From<getrandom::Error> for MechanismError {
|
||||||
fn from(err: getrandom::Error) -> MechanismError {
|
fn from(err: getrandom::Error) -> MechanismError {
|
||||||
MechanismError::RandomFailure(err)
|
MechanismError::RandomFailure(err)
|
||||||
|
|
Loading…
Reference in a new issue