Skip to content

Commit b74f5ca

Browse files
authored
feat(auth): add StoredCredentials::new() constructor (#778)
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 ac749e3 commit b74f5ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/rmcp/src/transport/auth.rs

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

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

0 commit comments

Comments
 (0)