struct SharedReads {
in_flight: Arc<Mutex<HashMap<String, Arc<PendingRead>>>>,
}Expand description
Keychain reads, at most one in flight per account.
A read runs on a detached thread, and its caller gives up after a timeout; the platform call underneath can’t be cancelled and stays queued behind an unanswered consent dialog. Without this, every retry queued another one: on 2026-10-08 an hour of once-a-minute retries behind one open dialog meant each Deny showed the next queued read’s dialog, six in two seconds. Now a read of an account that already has one in flight waits on that one, under its own timeout, so an open dialog stays one dialog. Nothing is cached: a read that starts after the answer arrived reads again.
Fields§
§in_flight: Arc<Mutex<HashMap<String, Arc<PendingRead>>>>Implementations§
fn new() -> Self
Sourcefn read(
&self,
account_id: &str,
timeout: Duration,
read: impl FnOnce() -> Result<Option<Zeroizing<String>>, String> + Send + 'static,
) -> Result<Result<Option<Zeroizing<String>>, String>, RunOutcome>
fn read( &self, account_id: &str, timeout: Duration, read: impl FnOnce() -> Result<Option<Zeroizing<String>>, String> + Send + 'static, ) -> Result<Result<Option<Zeroizing<String>>, String>, RunOutcome>
Wait up to timeout for account_id’s read, starting it with read
unless one is already in flight. The RunOutcome is separate from
any error the read itself returns; callers fold it into their own
message (run_outcome_message).
Sourcefn read_with(
&self,
account_id: &str,
timeout: Duration,
read: impl FnOnce() -> Result<Option<Zeroizing<String>>, String> + Send + 'static,
spawn: impl FnOnce(Box<dyn FnOnce() + Send>) -> Result<()>,
) -> Result<Result<Option<Zeroizing<String>>, String>, RunOutcome>
fn read_with( &self, account_id: &str, timeout: Duration, read: impl FnOnce() -> Result<Option<Zeroizing<String>>, String> + Send + 'static, spawn: impl FnOnce(Box<dyn FnOnce() + Send>) -> Result<()>, ) -> Result<Result<Option<Zeroizing<String>>, String>, RunOutcome>
read with the thread start passed in, so a test can
make it fail.
Sourcefn forget(&self, account_id: &str)
fn forget(&self, account_id: &str)
Stop sharing account_id’s in-flight read: the next read starts its
own. Called after a write, so no read that starts after it can get
the value from before it.
Sourcefn after_write<T>(
&self,
account_id: &str,
written: Result<T, String>,
) -> Result<T, String>
fn after_write<T>( &self, account_id: &str, written: Result<T, String>, ) -> Result<T, String>
Pass a write’s result through, forgetting the account’s in-flight read only if the write succeeded. A failed write changed nothing, and forgetting then would let the next retry start a second read beside the one still blocked on a dialog.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more