Skip to content

Commit 76b2fe3

Browse files
committed
Inline _encode and _decode
They had todos for docstrings, and I realized they're single-use and should probably not be exposed publicly anyway.
1 parent d6151bd commit 76b2fe3

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

src/decoding.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,12 @@ pub fn decode<T: DeserializeOwned>(
256256
) -> Result<TokenData<T>> {
257257
let header = decode_header(token)?;
258258

259-
if validation.validate_signature && !(validation.algorithms.contains(&header.alg)) {
259+
if validation.validate_signature && !validation.algorithms.contains(&header.alg) {
260260
return Err(new_error(ErrorKind::InvalidAlgorithm));
261261
}
262262

263263
let verifying_provider = jwt_verifier_factory(&header.alg, key)?;
264264

265-
_decode(token, validation, verifying_provider)
266-
}
267-
268-
/// # Todo
269-
///
270-
/// - Documentation
271-
pub fn _decode<T: DeserializeOwned>(
272-
token: &str,
273-
validation: &Validation,
274-
verifying_provider: Box<dyn JwtVerifier>,
275-
) -> Result<TokenData<T>> {
276265
let (header, claims) = verify_signature(token, validation, verifying_provider)?;
277266

278267
let decoded_claims = DecodedJwtPartClaims::from_jwt_part_claims(claims)?;

src/encoding.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,6 @@ pub fn encode<T: Serialize>(header: &Header, claims: &T, key: &EncodingKey) -> R
153153

154154
let signing_provider = jwt_signer_factory(&header.alg, key)?;
155155

156-
_encode(header, claims, signing_provider)
157-
}
158-
159-
/// # Todo
160-
///
161-
/// - Documentation
162-
pub fn _encode<T: Serialize>(
163-
header: &Header,
164-
claims: &T,
165-
signing_provider: Box<dyn JwtSigner>,
166-
) -> Result<String> {
167156
if signing_provider.algorithm() != header.alg {
168157
return Err(new_error(ErrorKind::InvalidAlgorithm));
169158
}

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ compile_error!(
99
);
1010

1111
#[cfg(not(any(feature = "rust_crypto", feature = "aws_lc_rs")))]
12-
compile_error!(
13-
"at least one of the features \"rust_crypto\" or \"aws_lc_rs\" must be enabled"
14-
);
12+
compile_error!("at least one of the features \"rust_crypto\" or \"aws_lc_rs\" must be enabled");
1513

1614
pub use algorithms::Algorithm;
17-
pub use decoding::{decode, decode_header, DecodingKey, TokenData, _decode};
18-
pub use encoding::{encode, EncodingKey, _encode};
15+
pub use decoding::{decode, decode_header, DecodingKey, TokenData};
16+
pub use encoding::{encode, EncodingKey};
1917
pub use header::Header;
2018
pub use validation::{get_current_timestamp, Validation};
2119

@@ -31,4 +29,4 @@ pub mod jwk;
3129
#[cfg(feature = "use_pem")]
3230
mod pem;
3331
mod serialization;
34-
mod validation;
32+
mod validation;

0 commit comments

Comments
 (0)