pub struct PasswordHashRuntime { /* private fields */ }Expand description
Instance-owned blocking executor with a memory/CPU concurrency budget.
Implementations§
Source§impl PasswordHashRuntime
impl PasswordHashRuntime
Sourcepub fn new(max_concurrency: usize) -> Result<Self, PasswordWorkError>
pub fn new(max_concurrency: usize) -> Result<Self, PasswordWorkError>
Creates an executor using the Forge default password policy.
§Errors
Returns InvalidConcurrency if the requested concurrency is zero.
Sourcepub fn with_policy(
max_concurrency: usize,
policy: PasswordHashPolicy,
) -> Result<Self, PasswordWorkError>
pub fn with_policy( max_concurrency: usize, policy: PasswordHashPolicy, ) -> Result<Self, PasswordWorkError>
Creates an executor with an explicit policy and positive concurrency limit.
§Errors
Returns InvalidConcurrency if the requested concurrency is zero.
Sourcepub async fn hash_password(
&self,
password: &str,
) -> Result<String, PasswordWorkError>
pub async fn hash_password( &self, password: &str, ) -> Result<String, PasswordWorkError>
Hashes a password on the blocking pool after acquiring an execution permit.
§Errors
Returns an error when the worker is closed, fails, or cannot hash the input.
Sourcepub async fn try_verify_password(
&self,
password: &str,
stored_hash: &str,
) -> Result<PasswordHashVerification, PasswordWorkError>
pub async fn try_verify_password( &self, password: &str, stored_hash: &str, ) -> Result<PasswordHashVerification, PasswordWorkError>
Fail immediately when the CPU/memory budget is occupied. The blocking job owns the permit, so cancellation cannot release capacity prematurely.
§Errors
Returns Busy on saturation, or a worker/cryptographic error.
Sourcepub async fn verify_password(
&self,
password: &str,
stored_hash: &str,
) -> Result<PasswordHashVerification, PasswordWorkError>
pub async fn verify_password( &self, password: &str, stored_hash: &str, ) -> Result<PasswordHashVerification, PasswordWorkError>
Verifies a password on the blocking pool after acquiring an execution permit.
§Errors
Returns an error when the worker fails or the stored verifier is invalid.
Trait Implementations§
Source§impl Clone for PasswordHashRuntime
impl Clone for PasswordHashRuntime
Source§fn clone(&self) -> PasswordHashRuntime
fn clone(&self) -> PasswordHashRuntime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more