pub struct GdprUseCases { /* private fields */ }Expand description
GDPR Use Cases for data export and erasure operations Implements business logic for GDPR Articles 15, 16, 17, 18, 21
Implementations§
Source§impl GdprUseCases
impl GdprUseCases
pub fn new( gdpr_repository: Arc<dyn GdprRepository>, user_repository: Arc<dyn UserRepository>, ) -> Self
Sourcepub async fn export_user_data(
&self,
user_id: Uuid,
requesting_user_id: Uuid,
organization_id: Option<Uuid>,
) -> Result<GdprExportResponseDto, String>
pub async fn export_user_data( &self, user_id: Uuid, requesting_user_id: Uuid, organization_id: Option<Uuid>, ) -> Result<GdprExportResponseDto, String>
Export all personal data for a user (GDPR Article 15 - Right to Access)
§Arguments
user_id- UUID of the user requesting data exportrequesting_user_id- UUID of the user making the request (for authorization)organization_id- Optional organization scope (None for SuperAdmin)
§Authorization
- Users can only export their own data
- SuperAdmin can export any user’s data
§Returns
Ok(GdprExportResponseDto)- Complete data export in JSON formatErr(String)- If user not found, not authorized, or database error
Sourcepub async fn erase_user_data(
&self,
user_id: Uuid,
requesting_user_id: Uuid,
organization_id: Option<Uuid>,
) -> Result<GdprEraseResponseDto, String>
pub async fn erase_user_data( &self, user_id: Uuid, requesting_user_id: Uuid, organization_id: Option<Uuid>, ) -> Result<GdprEraseResponseDto, String>
Erase user data by anonymization (GDPR Article 17 - Right to Erasure)
Anonymizes user account and linked owner profiles. Does not delete data entirely to preserve referential integrity and comply with legal retention requirements (e.g., financial records must be kept for 7 years in Belgium).
§Arguments
user_id- UUID of the user to anonymizerequesting_user_id- UUID of the user making the request (for authorization)organization_id- Optional organization scope (None for SuperAdmin)
§Authorization
- Users can only erase their own data
- SuperAdmin can erase any user’s data
§Returns
Ok(GdprEraseResponseDto)- Anonymization confirmationErr(String)- If user not found, not authorized, already anonymized, or legal holds exist
Sourcepub async fn rectify_user_data(
&self,
user_id: Uuid,
requesting_user_id: Uuid,
email: Option<String>,
first_name: Option<String>,
last_name: Option<String>,
) -> Result<(), String>
pub async fn rectify_user_data( &self, user_id: Uuid, requesting_user_id: Uuid, email: Option<String>, first_name: Option<String>, last_name: Option<String>, ) -> Result<(), String>
Rectify user personal data (GDPR Article 16 - Right to Rectification)
Allows users to correct inaccurate or incomplete personal data.
§Arguments
user_id- UUID of the user whose data to rectifyrequesting_user_id- UUID of the user making the request (for authorization)email- Optional new email addressfirst_name- Optional new first namelast_name- Optional new last name
§Authorization
- Users can only rectify their own data
- SuperAdmin can rectify any user’s data (organization_id = None)
§Returns
Ok(User)- Updated user entityErr(String)- If user not found, not authorized, or validation error
Sourcepub async fn restrict_user_processing(
&self,
user_id: Uuid,
requesting_user_id: Uuid,
) -> Result<(), String>
pub async fn restrict_user_processing( &self, user_id: Uuid, requesting_user_id: Uuid, ) -> Result<(), String>
Restrict data processing (GDPR Article 18 - Right to Restriction of Processing)
Allows users to request temporary limitation of data processing. When processing is restricted:
- Data is stored but not processed for certain operations
- Marketing communications are blocked
- Profiling/analytics are disabled
§Arguments
user_id- UUID of the userrequesting_user_id- UUID of the user making the request (for authorization)
§Authorization
- Users can only restrict their own data processing
§Returns
Ok(())- Processing restriction appliedErr(String)- If user not found, not authorized, or already restricted
Sourcepub async fn unrestrict_user_processing(
&self,
user_id: Uuid,
) -> Result<(), String>
pub async fn unrestrict_user_processing( &self, user_id: Uuid, ) -> Result<(), String>
Unrestrict data processing (Admin action or legal requirement met)
§Arguments
user_id- UUID of the useradmin_user_id- UUID of the admin performing the action
§Authorization
- Only admins/SuperAdmin can unrestrict processing
§Returns
Ok(())- Processing restriction removedErr(String)- If user not found
Sourcepub async fn set_marketing_preference(
&self,
user_id: Uuid,
requesting_user_id: Uuid,
opt_out: bool,
) -> Result<(), String>
pub async fn set_marketing_preference( &self, user_id: Uuid, requesting_user_id: Uuid, opt_out: bool, ) -> Result<(), String>
Set marketing opt-out preference (GDPR Article 21 - Right to Object)
Allows users to object to marketing communications and profiling.
§Arguments
user_id- UUID of the userrequesting_user_id- UUID of the user making the request (for authorization)opt_out- true to opt out of marketing, false to opt back in
§Authorization
- Users can only change their own marketing preferences
§Returns
Ok(())- Marketing preference updatedErr(String)- If user not found or not authorized
Auto Trait Implementations§
impl Freeze for GdprUseCases
impl !RefUnwindSafe for GdprUseCases
impl Send for GdprUseCases
impl Sync for GdprUseCases
impl Unpin for GdprUseCases
impl !UnwindSafe for GdprUseCases
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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