Skip to main content

ValidateConsent

Trait ValidateConsent 

Source
pub trait ValidateConsent {
    // Required method
    fn as_bool(&self) -> bool;

    // Provided methods
    fn accepted(&self) -> bool { ... }
    fn declined(&self) -> bool { ... }
}
Expand description

A trait for types that can be validated as representing consent.

This trait allows various types (like bool, String, &str) to be interpreted as either an “accepted” or “declined” state.

Required Methods§

Source

fn as_bool(&self) -> bool

Converts the value to a boolean representation of consent. true generally means accepted, false generally means declined.

Provided Methods§

Source

fn accepted(&self) -> bool

Checks if the value represents an “accepted” state. By default, this is true if as_bool() is true.

Source

fn declined(&self) -> bool

Checks if the value represents a “declined” state. By default, this is true if as_bool() is false.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ValidateConsent for &str

Implementation of ValidateConsent for &str. Recognizes “true”, “1”, “on”, “yes” (case-insensitive) as “accepted”. All other string slice values are considered “declined”.

Source§

fn as_bool(&self) -> bool

Source§

impl ValidateConsent for String

Implementation of ValidateConsent for String. Recognizes “true”, “1”, “on”, “yes” (case-insensitive) as “accepted”. All other string values are considered “declined”.

Source§

fn as_bool(&self) -> bool

Source§

impl ValidateConsent for bool

Implementation of ValidateConsent for bool.

  • true is considered “accepted”.
  • false is considered “declined”.
Source§

fn as_bool(&self) -> bool

Implementors§