pub enum MaybeUntrusted<Insecure, Trusted = Insecure> {
Ok(Trusted),
Untrusted(UntrustedValue<Insecure>),
}
Expand description
Represents a value that might be untrusted. See UntrustedValue
for more information.
Variants§
Implementations§
Source§impl<Insecure> MaybeUntrusted<Insecure>
impl<Insecure> MaybeUntrusted<Insecure>
Sourcepub fn use_untrusted_value(self) -> Insecure
pub fn use_untrusted_value(self) -> Insecure
Be sure that you carefully handle the returned value since
it may be controllable by a malicious actor (when it is a MaybeUntrusted::Untrusted
).
See the method documentation of the function returning this value
Source§impl<Insecure, Trusted> MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> MaybeUntrusted<Insecure, Trusted>
Sourcepub fn is_untrusted(&self) -> bool
pub fn is_untrusted(&self) -> bool
Returns true if the value is untrusted
Sourcepub fn wrap_untrusted(value: Insecure) -> Self
pub fn wrap_untrusted(value: Insecure) -> Self
Wraps the provided values as Untrusted
Trait Implementations§
Source§impl<Insecure, Trusted> From<UntrustedValue<Insecure>> for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> From<UntrustedValue<Insecure>> for MaybeUntrusted<Insecure, Trusted>
Source§fn from(value: UntrustedValue<Insecure>) -> Self
fn from(value: UntrustedValue<Insecure>) -> Self
Converts an UntrustedValue
to a MaybeUntrusted
value
Source§impl<E, Insecure: SanitizeValue<Insecure, Error = E>> SanitizeValue<Insecure> for MaybeUntrusted<Insecure>
impl<E, Insecure: SanitizeValue<Insecure, Error = E>> SanitizeValue<Insecure> for MaybeUntrusted<Insecure>
Source§impl<Insecure, Trusted> SanitizeWith<Insecure, Trusted> for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> SanitizeWith<Insecure, Trusted> for MaybeUntrusted<Insecure, Trusted>
Source§fn sanitize_with<Sanitizer, Error>(
self,
sanitizer: Sanitizer,
) -> Result<Trusted, Error>
fn sanitize_with<Sanitizer, Error>( self, sanitizer: Sanitizer, ) -> Result<Trusted, Error>
Sanitizes the value using the provided sanitizer if the value is untrusted.
The sanitizer may transmute the value to a different type. If sanitization fails, an error must be returned.
impl<Insecure: Copy, Trusted: Copy> Copy for MaybeUntrusted<Insecure, Trusted>
Auto Trait Implementations§
impl<Insecure, Trusted> Freeze for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> RefUnwindSafe for MaybeUntrusted<Insecure, Trusted>where
Trusted: RefUnwindSafe,
Insecure: RefUnwindSafe,
impl<Insecure, Trusted> Send for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> Sync for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> Unpin for MaybeUntrusted<Insecure, Trusted>
impl<Insecure, Trusted> UnwindSafe for MaybeUntrusted<Insecure, Trusted>where
Trusted: UnwindSafe,
Insecure: UnwindSafe,
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,
Source§impl<Insecure, OtherInsecure> FromTrustedVariant<OtherInsecure> for Insecurewhere
OtherInsecure: IntoUntrustedVariant<Insecure>,
impl<Insecure, OtherInsecure> FromTrustedVariant<OtherInsecure> for Insecurewhere
OtherInsecure: IntoUntrustedVariant<Insecure>,
Source§fn from_untrusted_variant(other: OtherInsecure) -> Insecure
fn from_untrusted_variant(other: OtherInsecure) -> Insecure
Converts the provided type to an equivalent untrusted type.
No sanitization is done here, only the conversion to an untrusted type.
This function MUST guarantee the following properties:
- The conversion result MUST NOT contain untainted data that was tainted in the input.
- The conversion MUST NOT do any sanitization.
- If the input is not tainted, all parts of the output MUST be tainted.
This method is auto-implemented since the other
type implements the IntoUntrustedVariant
trait.