Skip to content

Commit 2956242

Browse files
sandydoobuehler
andauthored
feat: allow Application::load_from_file to accept paths (#583)
Makes `Application::load_from_file` a bit more ergonomic by allowing it to accept `String`, `str`, `PathBuf`, and `Path`. Co-authored-by: Christoph Bühler <[email protected]>
1 parent de1c389 commit 2956242

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/credentials/application.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use custom_error::custom_error;
22
use jsonwebtoken::{encode, Algorithm, EncodingKey, Header};
33
use serde::{Deserialize, Serialize};
44
use std::fs::read_to_string;
5+
use std::path::Path;
56

67
use crate::credentials::jwt::JwtClaims;
78

@@ -52,7 +53,7 @@ impl Application {
5253
/// println!("{:#?}", application);
5354
/// # Ok::<(), Box<dyn std::error::Error>>(())
5455
/// ```
55-
pub fn load_from_file(file_path: &str) -> Result<Self, ApplicationError> {
56+
pub fn load_from_file<P: AsRef<Path>>(file_path: P) -> Result<Self, ApplicationError> {
5657
let data = read_to_string(file_path).map_err(|e| ApplicationError::Io { source: e })?;
5758
Application::load_from_json(data.as_str())
5859
}

0 commit comments

Comments
 (0)