Struct SlashReconcileState
pub struct SlashReconcileState {
pub app_id: Option<String>,
pub fingerprint: Option<u64>,
pub last_success_at: Option<i64>,
pub retry_after_until: Option<i64>,
}Expand description
Persisted reconcile state for one Discord application.
Fields§
§app_id: Option<String>Application id this state belongs to. State recorded for a different application (e.g. a swapped bot token) is ignored on load, degrading to a full reconcile rather than trusting a stale fingerprint.
fingerprint: Option<u64>Fingerprint of the last successfully reconciled command set.
last_success_at: Option<i64>Unix seconds of the last successful reconcile (diagnostic).
retry_after_until: Option<i64>Unix-seconds deadline before which no reconcile should be attempted,
recorded from a 429 Retry-After. None once a reconcile succeeds.
Implementations§
Source§impl SlashReconcileState
impl SlashReconcileState
Sourcepub fn load(workspace_dir: Option<&Path>, app_id: &str) -> Self
pub fn load(workspace_dir: Option<&Path>, app_id: &str) -> Self
Load persisted state for app_id. Returns the default (empty) state —
which forces a full reconcile — when no workspace dir is configured, the
file is absent or unreadable, or the recorded application id does not
match. Never fails; a corrupt or foreign file simply yields “no state”.
Sourcepub fn record_success(
workspace_dir: Option<&Path>,
app_id: &str,
fingerprint: u64,
now: i64,
)
pub fn record_success( workspace_dir: Option<&Path>, app_id: &str, fingerprint: u64, now: i64, )
Record a successful reconcile: store the fingerprint, clear any
Retry-After cooldown. Best-effort — a write failure is logged at debug
and otherwise ignored (the in-process flow already succeeded).
Sourcepub fn record_retry_after(
workspace_dir: Option<&Path>,
app_id: &str,
prev: &Self,
until: i64,
)
pub fn record_retry_after( workspace_dir: Option<&Path>, app_id: &str, prev: &Self, until: i64, )
Record a rate-limit cooldown observed during reconcile. The prior fingerprint is preserved (the desired set did not change, only the server asked us to wait), so the cooldown — not a forced re-diff — gates the next attempt.
Sourcepub fn rate_limited(&self, now: i64) -> bool
pub fn rate_limited(&self, now: i64) -> bool
True when a recorded Retry-After cooldown is still in the future.
Trait Implementations§
Source§impl Clone for SlashReconcileState
impl Clone for SlashReconcileState
Source§fn clone(&self) -> SlashReconcileState
fn clone(&self) -> SlashReconcileState
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SlashReconcileState
impl Debug for SlashReconcileState
Source§impl Default for SlashReconcileState
impl Default for SlashReconcileState
Source§fn default() -> SlashReconcileState
fn default() -> SlashReconcileState
Source§impl<'de> Deserialize<'de> for SlashReconcileState
impl<'de> Deserialize<'de> for SlashReconcileState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SlashReconcileState
impl PartialEq for SlashReconcileState
Source§fn eq(&self, other: &SlashReconcileState) -> bool
fn eq(&self, other: &SlashReconcileState) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SlashReconcileState
impl Serialize for SlashReconcileState
impl StructuralPartialEq for SlashReconcileState
Auto Trait Implementations§
impl Freeze for SlashReconcileState
impl RefUnwindSafe for SlashReconcileState
impl Send for SlashReconcileState
impl Sync for SlashReconcileState
impl Unpin for SlashReconcileState
impl UnsafeUnpin for SlashReconcileState
impl UnwindSafe for SlashReconcileState
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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