pub struct ConsentManager { /* private fields */ }Expand description
Manager for consent records with in-memory storage. In production, this would be backed by persistent storage.
Implementations§
Source§impl ConsentManager
impl ConsentManager
Sourcepub fn with_data_dir(data_dir: Option<PathBuf>) -> Self
pub fn with_data_dir(data_dir: Option<PathBuf>) -> Self
Create a new consent manager with optional disk persistence.
If data_dir is provided, attempts to load existing data from {data_dir}/consent.json.
Sourcepub fn record_consent(
&self,
subject_id: &str,
purpose: Purpose,
granted: bool,
source: ConsentSource,
version: &str,
expires_at: Option<u64>,
metadata: Option<HashMap<String, String>>,
actor: &str,
) -> ConsentRecord
pub fn record_consent( &self, subject_id: &str, purpose: Purpose, granted: bool, source: ConsentSource, version: &str, expires_at: Option<u64>, metadata: Option<HashMap<String, String>>, actor: &str, ) -> ConsentRecord
Record new consent or update existing consent.
Sourcepub fn get_consent(&self, subject_id: &str) -> Vec<ConsentRecord>
pub fn get_consent(&self, subject_id: &str) -> Vec<ConsentRecord>
Get current consent status for a subject.
Sourcepub fn get_consent_for_purpose(
&self,
subject_id: &str,
purpose: Purpose,
) -> Option<ConsentRecord>
pub fn get_consent_for_purpose( &self, subject_id: &str, purpose: Purpose, ) -> Option<ConsentRecord>
Get consent for a specific purpose.
Sourcepub fn check_consent(&self, subject_id: &str, purpose: Purpose) -> bool
pub fn check_consent(&self, subject_id: &str, purpose: Purpose) -> bool
Check if consent is granted for a specific purpose. This is the main enforcement function to call before data operations.
Sourcepub fn withdraw_consent(
&self,
subject_id: &str,
purpose: Purpose,
actor: &str,
reason: Option<&str>,
) -> Result<ConsentRecord, String>
pub fn withdraw_consent( &self, subject_id: &str, purpose: Purpose, actor: &str, reason: Option<&str>, ) -> Result<ConsentRecord, String>
Withdraw consent for a specific purpose.
Sourcepub fn get_history(&self, subject_id: &str) -> Vec<ConsentHistoryEntry>
pub fn get_history(&self, subject_id: &str) -> Vec<ConsentHistoryEntry>
Get consent audit history for a subject.
Sourcepub fn get_history_for_purpose(
&self,
subject_id: &str,
purpose: Purpose,
) -> Vec<ConsentHistoryEntry>
pub fn get_history_for_purpose( &self, subject_id: &str, purpose: Purpose, ) -> Vec<ConsentHistoryEntry>
Get history for a specific purpose.
Sourcepub fn is_on_do_not_sell_list(&self, subject_id: &str) -> bool
pub fn is_on_do_not_sell_list(&self, subject_id: &str) -> bool
Check if a subject is on the CCPA Do Not Sell list.
Sourcepub fn get_do_not_sell_list(&self) -> Vec<String>
pub fn get_do_not_sell_list(&self) -> Vec<String>
Get all subjects on the Do Not Sell list.
Sourcepub fn export_subject_data(&self, subject_id: &str) -> SubjectConsentExport
pub fn export_subject_data(&self, subject_id: &str) -> SubjectConsentExport
Export all consent records for a subject (for data portability/GDPR).
Sourcepub fn delete_subject_data(&self, subject_id: &str, actor: &str) -> bool
pub fn delete_subject_data(&self, subject_id: &str, actor: &str) -> bool
Delete all consent records for a subject (for GDPR right to erasure).
Sourcepub fn get_stats(&self) -> ConsentStats
pub fn get_stats(&self) -> ConsentStats
Get statistics about consent records.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConsentManager
impl !RefUnwindSafe for ConsentManager
impl Send for ConsentManager
impl Sync for ConsentManager
impl Unpin for ConsentManager
impl UnsafeUnpin for ConsentManager
impl UnwindSafe for ConsentManager
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