From 7e8e688e2e58f9c944b941e768ab7b034a348a1f Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 1 Aug 2024 19:48:37 +0300 Subject: treewide: create a common method for state initialization Now the database objects can be uniformly created from a URI. They can also optionally do sanity checks and one-time initialization. --- src/indieauth/backend/fs.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/indieauth/backend/fs.rs') diff --git a/src/indieauth/backend/fs.rs b/src/indieauth/backend/fs.rs index 80c3703..5e97ae5 100644 --- a/src/indieauth/backend/fs.rs +++ b/src/indieauth/backend/fs.rs @@ -20,12 +20,6 @@ pub struct FileBackend { } impl FileBackend { - pub fn new>(path: T) -> Self { - Self { - path: path.into() - } - } - /// Sanitize a filename, leaving only alphanumeric characters. /// /// Doesn't allocate a new string unless non-alphanumeric @@ -193,6 +187,12 @@ impl FileBackend { #[async_trait] impl AuthBackend for FileBackend { + async fn new(path: &'_ url::Url) -> Result { + Ok(Self { + path: std::path::PathBuf::from(path.path()) + }) + } + // Authorization code management. async fn create_code(&self, data: AuthorizationRequest) -> Result { self.serialize_to_file("codes", None, CODE_LENGTH, data).await -- cgit 1.4.1