pub struct InstructionRule { /* private fields */ }Expand description
Rule that limits specific instruction types per wallet
Counts matching instructions in each transaction and enforces limits. Supports both lifetime limits (never resets) and time-windowed limits (resets periodically).
Currently supported instruction types:
- System: CreateAccount / CreateAccountWithSeed
- ATA: CreateIdempotent / Create
Implementations§
Source§impl InstructionRule
impl InstructionRule
pub fn new( program: Pubkey, instruction: String, max: u64, window_seconds: Option<u64>, ) -> Self
Sourcepub fn lifetime(program: Pubkey, instruction: String, max: u64) -> Self
pub fn lifetime(program: Pubkey, instruction: String, max: u64) -> Self
Create a lifetime instruction limit (never resets)
Sourcepub fn windowed(
program: Pubkey,
instruction: String,
max: u64,
window_seconds: u64,
) -> Self
pub fn windowed( program: Pubkey, instruction: String, max: u64, window_seconds: u64, ) -> Self
Create a time-windowed instruction limit
Sourcepub fn count_all_rules(
rules: &[&InstructionRule],
ctx: &mut LimiterContext<'_>,
) -> Vec<u64>
pub fn count_all_rules( rules: &[&InstructionRule], ctx: &mut LimiterContext<'_>, ) -> Vec<u64>
Count matching instructions for one or more rules in a single pass Only counts instructions where Kora is the payer (subsidized operations)
pub fn storage_key(&self, user_id: &str, timestamp: u64) -> String
Sourcepub fn count_increment(&self, ctx: &mut LimiterContext<'_>) -> u64
pub fn count_increment(&self, ctx: &mut LimiterContext<'_>) -> u64
How many units to increment for this transaction
Sourcepub fn window_seconds(&self) -> Option<u64>
pub fn window_seconds(&self) -> Option<u64>
Time window in seconds
pub fn description(&self) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InstructionRule
impl RefUnwindSafe for InstructionRule
impl Send for InstructionRule
impl Sync for InstructionRule
impl Unpin for InstructionRule
impl UnsafeUnpin for InstructionRule
impl UnwindSafe for InstructionRule
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.