Skip to content

Commit 7220060

Browse files
committed
feat(auth): add StoredCredentials::new() constructor
StoredCredentials is #[non_exhaustive] but has no constructor, making it impossible for external crates implementing CredentialStore to construct instances without a serde roundtrip workaround. Add a new() constructor matching the pattern used for other #[non_exhaustive] types in this crate. Fixes #777
1 parent 808e027 commit 7220060

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

crates/rmcp/src/transport/auth.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ impl std::fmt::Debug for StoredCredentials {
8383
}
8484
}
8585

86+
impl StoredCredentials {
87+
/// Create a new `StoredCredentials` instance.
88+
pub fn new(
89+
client_id: String,
90+
token_response: Option<OAuthTokenResponse>,
91+
granted_scopes: Vec<String>,
92+
token_received_at: Option<u64>,
93+
) -> Self {
94+
Self {
95+
client_id,
96+
token_response,
97+
granted_scopes,
98+
token_received_at,
99+
}
100+
}
101+
}
102+
86103
/// Trait for storing and retrieving OAuth2 credentials
87104
///
88105
/// Implementations of this trait can provide custom storage backends

0 commit comments

Comments
 (0)