pub struct SafetyGuard { /* private fields */ }Expand description
Combined safety guard for all automation loops.
Provides pre-flight checks that combine rate limiting with deduplication.
All automation loops should call SafetyGuard methods before taking actions.
Implementations§
Source§impl SafetyGuard
impl SafetyGuard
Sourcepub async fn can_reply_to(
&self,
tweet_id: &str,
proposed_reply: Option<&str>,
) -> Result<Result<(), DenialReason>, StorageError>
pub async fn can_reply_to( &self, tweet_id: &str, proposed_reply: Option<&str>, ) -> Result<Result<(), DenialReason>, StorageError>
Check whether replying to a tweet is permitted.
Checks rate limits, exact dedup, and optionally phrasing similarity.
Returns Ok(Ok(())) if allowed, Ok(Err(DenialReason)) if blocked,
or Err(StorageError) on infrastructure failure.
Sourcepub async fn can_post_tweet(
&self,
) -> Result<Result<(), DenialReason>, StorageError>
pub async fn can_post_tweet( &self, ) -> Result<Result<(), DenialReason>, StorageError>
Check whether posting an original tweet is permitted.
Only checks rate limits (no dedup for original tweets).
Sourcepub async fn can_post_thread(
&self,
) -> Result<Result<(), DenialReason>, StorageError>
pub async fn can_post_thread( &self, ) -> Result<Result<(), DenialReason>, StorageError>
Check whether posting a thread is permitted.
Only checks rate limits (no dedup for threads).
Check if replying to this author is permitted (per-author daily limit).
Sourcepub fn check_banned_phrases(
reply_text: &str,
banned: &[String],
) -> Result<(), DenialReason>
pub fn check_banned_phrases( reply_text: &str, banned: &[String], ) -> Result<(), DenialReason>
Check if a generated reply contains a banned phrase.
Record a reply for an author interaction.
Sourcepub async fn record_reply(&self) -> Result<(), StorageError>
pub async fn record_reply(&self) -> Result<(), StorageError>
Record a successful reply action.
Sourcepub async fn record_tweet(&self) -> Result<(), StorageError>
pub async fn record_tweet(&self) -> Result<(), StorageError>
Record a successful tweet action.
Sourcepub async fn record_thread(&self) -> Result<(), StorageError>
pub async fn record_thread(&self) -> Result<(), StorageError>
Record a successful thread action.
Sourcepub fn rate_limiter(&self) -> &RateLimiter
pub fn rate_limiter(&self) -> &RateLimiter
Get a reference to the underlying rate limiter.
Sourcepub fn dedup_checker(&self) -> &DedupChecker
pub fn dedup_checker(&self) -> &DedupChecker
Get a reference to the underlying dedup checker.
Auto Trait Implementations§
impl Freeze for SafetyGuard
impl !RefUnwindSafe for SafetyGuard
impl Send for SafetyGuard
impl Sync for SafetyGuard
impl Unpin for SafetyGuard
impl UnsafeUnpin for SafetyGuard
impl !UnwindSafe for SafetyGuard
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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