[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5f60a885-733e-4434-ac5e-a70005f11382@proton.me>
Date: Fri, 13 Sep 2024 13:47:15 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Finn Behrens <me@...enk.dev>
Cc: Greg KH <gregkh@...uxfoundation.org>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] rust: add untrusted data abstraction
On 13.09.24 15:41, Finn Behrens wrote:
> On 13 Sep 2024, at 13:26, Benno Lossin wrote:
>> +pub trait Validator {
>> + /// Type of the input data that is untrusted.
>> + type Input: ?Sized;
>
> I would like to explore this trait with being generic over Input, instead of having Input as an associated type. Might be nicer to have Validators for different input types if the valid data is always the same?
I think I have changed my opinion on this from Kangrejos, I like the
idea. Then we would also be able to do something like this:
impl<I> Validator<I> for Foo
where
I: Deref<Target = [u8]>,
{
/* ... */
}
---
Cheers,
Benno
>> + /// Type of the validated data.
>> + type Output;
>> + /// Validation error.
>> + type Err;
>> +
>> + /// Validate the given untrusted data and parse it into the output type.
>> + ///
>> + /// When implementing this function, you can use [`Untrusted::untrusted()`] to get access to
>> + /// the raw untrusted data.
>> + fn validate(untrusted: &Untrusted<Self::Input>) -> Result<Self::Output, Self::Err>;
>> +}
>> --
>> 2.46.0
Powered by blists - more mailing lists