pub struct SmartCollection {
pub collection: Collection,
pub rules: Vec<SmartRule>,
pub match_mode: MatchMode,
pub auto_update: bool,
pub last_updated: DateTime<Utc>,
pub poll_interval_secs: Option<u64>,
pub cached_clip_ids: Vec<ClipId>,
pub cache_valid: bool,
}Expand description
A smart collection that auto-updates based on rules.
Fields§
§collection: CollectionBase collection.
rules: Vec<SmartRule>Rules for matching clips.
match_mode: MatchModeMatch mode.
auto_update: boolAuto-update enabled.
last_updated: DateTime<Utc>Last update timestamp.
poll_interval_secs: Option<u64>Polling interval for auto-refresh in seconds. None means no polling.
cached_clip_ids: Vec<ClipId>Cached result: clip IDs that currently match the rules.
cache_valid: boolWhether the cache is considered valid.
Implementations§
Source§impl SmartCollection
impl SmartCollection
Sourcepub fn new(
name: impl Into<String>,
rules: Vec<SmartRule>,
match_mode: MatchMode,
) -> Self
pub fn new( name: impl Into<String>, rules: Vec<SmartRule>, match_mode: MatchMode, ) -> Self
Creates a new smart collection.
Sourcepub fn set_poll_interval(&mut self, interval: Duration)
pub fn set_poll_interval(&mut self, interval: Duration)
Sets the polling interval for auto-refresh.
When set, needs_refresh() will return true if more than interval
has elapsed since the last update.
Sourcepub fn clear_poll_interval(&mut self)
pub fn clear_poll_interval(&mut self)
Clears the polling interval (disables timed auto-refresh).
Sourcepub fn poll_interval(&self) -> Option<Duration>
pub fn poll_interval(&self) -> Option<Duration>
Returns the configured poll interval, if any.
Sourcepub fn needs_refresh(&self) -> bool
pub fn needs_refresh(&self) -> bool
Returns true if the collection should be refreshed.
Criteria:
auto_updateis enabled, AND- either the cache is marked invalid, OR the poll interval has elapsed.
Sourcepub fn invalidate_cache(&mut self)
pub fn invalidate_cache(&mut self)
Invalidates the cached results, forcing the next call to needs_refresh
(when auto_update is enabled) to return true.
Sourcepub fn cached_clip_ids(&self) -> Option<&[ClipId]>
pub fn cached_clip_ids(&self) -> Option<&[ClipId]>
Returns the cached clip IDs if the cache is valid.
Sourcepub const fn id(&self) -> CollectionId
pub const fn id(&self) -> CollectionId
Returns the collection ID.
Sourcepub fn matches(&self, clip: &Clip) -> bool
pub fn matches(&self, clip: &Clip) -> bool
Checks if a clip matches the smart collection rules.
Sourcepub fn update(&mut self, clips: &[Clip])
pub fn update(&mut self, clips: &[Clip])
Updates the collection by evaluating all clips.
Also refreshes the internal cache so that cached_clip_ids() returns
the up-to-date list.
Sourcepub fn refresh_if_needed(&mut self, clips: &[Clip]) -> bool
pub fn refresh_if_needed(&mut self, clips: &[Clip]) -> bool
Updates the collection only if needs_refresh() returns true.
Returns true if a refresh was performed.
Sourcepub fn remove_rule(&mut self, index: usize) -> Option<SmartRule>
pub fn remove_rule(&mut self, index: usize) -> Option<SmartRule>
Removes a rule at index.
Sourcepub fn set_match_mode(&mut self, mode: MatchMode)
pub fn set_match_mode(&mut self, mode: MatchMode)
Sets the match mode.
Trait Implementations§
Source§impl Clone for SmartCollection
impl Clone for SmartCollection
Source§fn clone(&self) -> SmartCollection
fn clone(&self) -> SmartCollection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SmartCollection
impl Debug for SmartCollection
Source§impl<'de> Deserialize<'de> for SmartCollection
impl<'de> Deserialize<'de> for SmartCollection
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 SmartCollection
impl RefUnwindSafe for SmartCollection
impl Send for SmartCollection
impl Sync for SmartCollection
impl Unpin for SmartCollection
impl UnsafeUnpin for SmartCollection
impl UnwindSafe for SmartCollection
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> 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> 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