pub struct RulesMap { /* private fields */ }Expand description
RulesMap - Rule mapping organized by event name。
event.RulesMap (map[Name]Rules) in the corresponding Go code
Implementations§
Source§impl RulesMap
impl RulesMap
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty RulesMap.
§Returns
A new instance of RulesMap with an empty map and a total_events_mask set to 0.
Sourcepub fn add_rule_config(
&mut self,
event_names: &[EventName],
pattern: String,
target_id: TargetID,
)
pub fn add_rule_config( &mut self, event_names: &[EventName], pattern: String, target_id: TargetID, )
Add a rule configuration to the map.
This method handles composite event names (such as s3:ObjectCreated:*), expanding them as
Multiple specific event types and add rules for each event type.
§Parameters
event_names- List of event names associated with this rule.pattern- Matching pattern for object keys. If empty, the default is*(match all).target_id- The target ID of the notification.
Sourcepub fn add_map(&mut self, other_map: &Self)
pub fn add_map(&mut self, other_map: &Self)
Merge another RulesMap. `RulesMap.Add(rulesMap2 RulesMap) corresponding to Go
§Parameters
other_map- The other RulesMap to be merged into the current one.
Sourcepub fn remove_map(&mut self, other_map: &Self)
pub fn remove_map(&mut self, other_map: &Self)
Remove another rule defined in the RulesMap from the current RulesMap.
After the rule is removed, total_events_mask is recalculated to ensure its accuracy.
§Parameters
other_map- The other RulesMap containing rules to be removed from the current one.
Sourcepub fn has_subscriber(&self, event_name: &EventName) -> bool
pub fn has_subscriber(&self, event_name: &EventName) -> bool
Checks whether any configured rules exist for a given event type.
This method uses a bitmask for a quick check of O(1) complexity.
event_name can be a compound type, such as ObjectCreatedAll.
§Parameters
event_name- The event name to check for subscribers.
Sourcepub fn match_rules(
&self,
event_name: EventName,
object_key: &str,
) -> TargetIdSet
pub fn match_rules( &self, event_name: EventName, object_key: &str, ) -> TargetIdSet
Rules matching the given event and object keys and return all matching target IDs.
§Notice
The event_name parameter should be a specific, non-compound event type.
Because this is taken from the Event object that actually occurs.
§Parameters
event_name- The specific event name to match against.object_key- The object key to match against the patterns in the rules.
§Returns
- A set of TargetIDs that match the given event and object key.
Sourcepub fn contains_target_id(&self, target_id: &TargetID) -> bool
pub fn contains_target_id(&self, target_id: &TargetID) -> bool
Sourcepub fn inner(&self) -> &HashMap<EventName, PatternRules>
pub fn inner(&self) -> &HashMap<EventName, PatternRules>
Returns a clone of internal rules for use in scenarios such as BucketNotificationConfig::validate.
§Returns
A reference to the internal HashMap of EventName to PatternRules.
Sourcepub fn remove_rule(&mut self, event_name: &EventName, pattern: &str)
pub fn remove_rule(&mut self, event_name: &EventName, pattern: &str)
Remove rules and optimize performance
§Parameters
event_name- The EventName from which to remove the rule.pattern- The pattern of the rule to be removed.
Sourcepub fn remove_rules(&mut self, event_names: &[EventName])
pub fn remove_rules(&mut self, event_names: &[EventName])
Batch Delete Rules and Optimize Performance
§Parameters
event_names- A slice of EventNames to be removed.
Sourcepub fn update_rule(
&mut self,
event_name: EventName,
pattern: String,
target_id: TargetID,
)
pub fn update_rule( &mut self, event_name: EventName, pattern: String, target_id: TargetID, )
Update rules and optimize performance
§Parameters
event_name- The EventName to update.pattern- The pattern of the rule to be updated.target_id- The TargetID to be added.
Sourcepub fn iter_events(&self) -> impl Iterator<Item = EventName> + '_
pub fn iter_events(&self) -> impl Iterator<Item = EventName> + '_
Iterate all EventName keys contained in this RulesMap.
Used by snapshot compilation to compute bucket event_mask.
§Returns
An iterator over all EventName keys in the RulesMap.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RulesMap
impl<'de> Deserialize<'de> for RulesMap
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>,
Auto Trait Implementations§
impl Freeze for RulesMap
impl RefUnwindSafe for RulesMap
impl Send for RulesMap
impl Sync for RulesMap
impl Unpin for RulesMap
impl UnsafeUnpin for RulesMap
impl UnwindSafe for RulesMap
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request