Struct sentry::db::campaign::CampaignRemaining
source · pub struct CampaignRemaining { /* private fields */ }
Implementations
sourceimpl CampaignRemaining
impl CampaignRemaining
pub const CAMPAIGN_REMAINING_KEY: &'static str = "campaignRemaining"
pub fn get_key(campaign: CampaignId) -> String
pub fn new(redis: MultiplexedConnection) -> Self
pub async fn set_initial(
&self,
campaign: CampaignId,
amount: UnifiedNum
) -> Result<bool, RedisError>
pub async fn get_remaining_opt(
&self,
campaign: CampaignId
) -> Result<Option<i64>, RedisError>
sourcepub async fn get_multiple(
&self,
campaigns: &[CampaignId]
) -> Result<Vec<UnifiedNum>, RedisError>
pub async fn get_multiple(
&self,
campaigns: &[CampaignId]
) -> Result<Vec<UnifiedNum>, RedisError>
This method uses max(0, value)
to clamp the value of a campaign, which can be negative and uses i64
.
In addition, it defaults the campaign keys that were not found to 0
.
sourcepub async fn get_multiple_with_ids(
&self,
campaigns: &[CampaignId]
) -> Result<HashMap<CampaignId, UnifiedNum>, RedisError>
pub async fn get_multiple_with_ids(
&self,
campaigns: &[CampaignId]
) -> Result<HashMap<CampaignId, UnifiedNum>, RedisError>
This method will get the remaining of the provided Campaign
s
and it will also match the returned values to the [CampaignId
]s
MGET
should always return results in the same order!
pub async fn increase_by(
&self,
campaign: CampaignId,
amount: UnifiedNum
) -> Result<i64, RedisError>
pub async fn decrease_by(
&self,
campaign: CampaignId,
amount: UnifiedNum
) -> Result<i64, RedisError>
sourcepub async fn getset_remaining_to_zero(
&self,
campaign: CampaignId
) -> Result<u64, RedisError>
pub async fn getset_remaining_to_zero(
&self,
campaign: CampaignId
) -> Result<u64, RedisError>
Atomic getset
[redis
] operation
Used to close a [primitives::Campaign
] POST /campaign/close
Trait Implementations
sourceimpl Clone for CampaignRemaining
impl Clone for CampaignRemaining
sourcefn clone(&self) -> CampaignRemaining
fn clone(&self) -> CampaignRemaining
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations
impl !RefUnwindSafe for CampaignRemaining
impl Send for CampaignRemaining
impl Sync for CampaignRemaining
impl Unpin for CampaignRemaining
impl !UnwindSafe for CampaignRemaining
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more