diff --git a/crates/data-model/src/tokens.rs b/crates/data-model/src/tokens.rs index e992f59b0..b4c8ede28 100644 --- a/crates/data-model/src/tokens.rs +++ b/crates/data-model/src/tokens.rs @@ -225,16 +225,6 @@ impl TokenType { } /// Generate a token for the given type - /// - /// ```rust - /// extern crate rand; - /// - /// use rand::thread_rng; - /// use mas_data_model::TokenType::{AccessToken, RefreshToken}; - /// - /// AccessToken.generate(&mut thread_rng()); - /// RefreshToken.generate(&mut thread_rng()); - /// ``` pub fn generate(self, rng: &mut (impl RngCore + ?Sized)) -> String { let random_part: String = rng .sample_iter(&Alphanumeric) @@ -250,25 +240,6 @@ impl TokenType { /// Check the format of a token and determine its type /// - /// ```rust - /// use mas_data_model::TokenType; - /// - /// assert_eq!( - /// TokenType::check("mat_kkLSacJDpek22jKWw4AcXG68b7U3W6_0Lg9yb"), - /// Ok(TokenType::AccessToken) - /// ); - /// - /// assert_eq!( - /// TokenType::check("mar_PkpplxPkfjsqvtdfUlYR1Afg2TpaHF_GaTQd2"), - /// Ok(TokenType::RefreshToken) - /// ); - /// - /// assert_eq!( - /// TokenType::check("syt_PkpplxPkfjsqvtdfUlYR1Afg2TpaHF_GaTQd2"), - /// Ok(TokenType::CompatAccessToken) - /// ); - /// ``` - /// /// # Errors /// /// Returns an error if the token is not valid diff --git a/crates/handlers/src/passwords.rs b/crates/handlers/src/passwords.rs index 18dd7fa42..e227f4400 100644 --- a/crates/handlers/src/passwords.rs +++ b/crates/handlers/src/passwords.rs @@ -42,18 +42,6 @@ impl PasswordManager { /// complexity score between 0 and 4. The first item in /// the iterator will be the default hashing scheme. /// - /// # Example - /// - /// ```rust - /// pub use mas_handlers::passwords::{PasswordManager, Hasher}; - /// - /// PasswordManager::new(3, [ - /// (3, Hasher::argon2id(Some(b"a-secret-pepper".to_vec()))), - /// (2, Hasher::argon2id(None)), - /// (1, Hasher::bcrypt(Some(10), None)), - /// ]).unwrap(); - /// ``` - /// /// # Errors /// /// Returns an error if the iterator was empty diff --git a/crates/keystore/src/lib.rs b/crates/keystore/src/lib.rs index 0c11e4928..fcb00cf5e 100644 --- a/crates/keystore/src/lib.rs +++ b/crates/keystore/src/lib.rs @@ -611,24 +611,6 @@ pub struct Keystore { impl Keystore { /// Create a keystore out of a JSON Web Key Set - /// - /// ```rust - /// use mas_keystore::{Keystore, PrivateKey, JsonWebKey, JsonWebKeySet}; - /// let rsa = PrivateKey::load_pem(include_str!("../tests/keys/rsa.pkcs1.pem")).unwrap(); - /// let rsa = JsonWebKey::new(rsa); - /// - /// let ec_p256 = PrivateKey::load_pem(include_str!("../tests/keys/ec-p256.sec1.pem")).unwrap(); - /// let ec_p256 = JsonWebKey::new(ec_p256); - /// - /// let ec_p384 = PrivateKey::load_pem(include_str!("../tests/keys/ec-p384.sec1.pem")).unwrap(); - /// let ec_p384 = JsonWebKey::new(ec_p384); - /// - /// let ec_k256 = PrivateKey::load_pem(include_str!("../tests/keys/ec-k256.sec1.pem")).unwrap(); - /// let ec_k256 = JsonWebKey::new(ec_k256); - /// - /// let jwks = JsonWebKeySet::new(vec![rsa, ec_p256, ec_p384, ec_k256]); - /// let keystore = Keystore::new(jwks); - /// ``` #[must_use] pub fn new(keys: JsonWebKeySet) -> Self { let keys = Arc::new(keys); diff --git a/crates/oauth2-types/src/oidc.rs b/crates/oauth2-types/src/oidc.rs index 011caaa9c..c2fa68ecc 100644 --- a/crates/oauth2-types/src/oidc.rs +++ b/crates/oauth2-types/src/oidc.rs @@ -925,32 +925,6 @@ impl ProviderMetadata { /// /// To access other fields, use this type's `Deref` implementation. /// -/// # Example -/// -/// ```no_run -/// use oauth2_types::{ -/// oidc::VerifiedProviderMetadata, -/// requests::GrantType, -/// }; -/// use url::Url; -/// # use oauth2_types::oidc::{ProviderMetadata, ProviderMetadataVerificationError}; -/// # let metadata = ProviderMetadata::default(); -/// # let issuer = "http://localhost/"; -/// let verified_metadata = metadata.validate(&issuer)?; -/// -/// // The endpoint is required during validation so this is not an `Option`. -/// let _: &Url = verified_metadata.authorization_endpoint(); -/// -/// // The field has a default value so this is not an `Option`. -/// let _: &[GrantType] = verified_metadata.grant_types_supported(); -/// -/// // Other fields can be accessed via `Deref`. -/// if let Some(registration_endpoint) = &verified_metadata.registration_endpoint { -/// println!("Registration is supported at {registration_endpoint}"); -/// } -/// # Ok::<(), ProviderMetadataVerificationError>(()) -/// ``` -/// /// [OpenID Connect Discovery Spec 1.0]: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata #[derive(Debug, Clone)] pub struct VerifiedProviderMetadata { diff --git a/crates/oauth2-types/src/registration/mod.rs b/crates/oauth2-types/src/registration/mod.rs index 88ba869aa..40ea147f1 100644 --- a/crates/oauth2-types/src/registration/mod.rs +++ b/crates/oauth2-types/src/registration/mod.rs @@ -769,33 +769,6 @@ impl ClientMetadata { /// /// To access other fields, use this type's `Deref` implementation. /// -/// # Example -/// -/// ```no_run -/// use oauth2_types::{ -/// oidc::ApplicationType, -/// registration::VerifiedClientMetadata, -/// requests::GrantType, -/// }; -/// use url::Url; -/// # use oauth2_types::registration::{ClientMetadata, ClientMetadataVerificationError}; -/// # let metadata = ClientMetadata::default(); -/// # let issuer = Url::parse("http://localhost").unwrap(); -/// let verified_metadata = metadata.validate()?; -/// -/// // The redirect URIs are required during validation so this is not an `Option`. -/// let _: &[Url] = verified_metadata.redirect_uris(); -/// -/// // The field has a default value so this is not an `Option`. -/// let _: ApplicationType = verified_metadata.application_type(); -/// -/// // Other fields can be accessed via `Deref`. -/// if let Some(jwks_uri) = &verified_metadata.jwks_uri { -/// println!("Client's JWK Set is available at {jwks_uri}"); -/// } -/// # Ok::<(), ClientMetadataVerificationError>(()) -/// ``` -/// /// [OpenID Connect Dynamic Client Registration Spec 1.0]: https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata #[derive(Serialize, Debug, PartialEq, Eq, Clone)] #[serde(into = "ClientMetadataSerdeHelper")] diff --git a/crates/storage/src/clock.rs b/crates/storage/src/clock.rs index c7fc235e0..c19f54fc9 100644 --- a/crates/storage/src/clock.rs +++ b/crates/storage/src/clock.rs @@ -48,20 +48,6 @@ impl Clock for SystemClock { /// A fake clock, which uses a fixed timestamp, and can be advanced with the /// [`MockClock::advance`] method. -/// -/// ```rust -/// use mas_storage::clock::{Clock, MockClock}; -/// use chrono::Duration; -/// -/// let clock = MockClock::default(); -/// let t1 = clock.now(); -/// let t2 = clock.now(); -/// assert_eq!(t1, t2); -/// -/// clock.advance(Duration::microseconds(10 * 1000 * 1000)); -/// let t3 = clock.now(); -/// assert_eq!(t2 + Duration::microseconds(10 * 1000 * 1000), t3); -/// ``` pub struct MockClock { timestamp: AtomicI64, } diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 129e48b06..f2f699ba6 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -32,20 +32,7 @@ //! //! The repository trait definition should look like this: //! -//! ```rust -//! # use async_trait::async_trait; -//! # use ulid::Ulid; -//! # use rand_core::RngCore; -//! # use mas_storage::Clock; -//! # -//! # // A fake data structure, usually defined in mas-data-model -//! # struct FakeData { -//! # id: Ulid, -//! # } -//! # -//! # // A fake empty macro, to replace `mas_storage::repository_impl` -//! # macro_rules! repository_impl { ($($tok:tt)*) => {} } -//! +//! ```ignore //! #[async_trait] //! pub trait FakeDataRepository: Send + Sync { //! /// The error type returned by the repository @@ -108,11 +95,7 @@ //! Then update the [`RepositoryAccess`] trait to make the new repository //! available: //! -//! ```rust -//! # trait FakeDataRepository { -//! # type Error; -//! # } -//! +//! ```ignore //! /// Access the various repositories the backend implements. //! pub trait RepositoryAccess: Send { //! /// The backend-specific error type used by each repository.