You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide FromSql impls for *const str and *const [u8]
There are several impls which could be composed on impls for `&str` and
`&[u8]` if they were available. Unfortunately, providing those impls is
impossible in Diesel 1.0. We would need a lifetime on `FromSql`,
changing the signature to this:
```rust
trait FromSql<'a, ST, DB> {
fn from_sql(bytes: Option<&'a DB::RawValue>) -> ...
}
```
While we can't provide impls for `&str` and `&[u8]`, we can provide
impls for `*const` versions of both. The docs about how long the pointer
is valid for *do* get rendered, and since dereferencing this pointers
requires unsafe code, we can reasonably assume that anyone who uses
these impls has looked at the docs for the assumed invaraints.
I've updated several of our built-in impls that just do string parsing
to use these impls, to demonstrate why they're useful. Keep in mind that
outside of Diesel it is impossible to reference `SqliteValue`. While the
impls I've updated are backend specific, it is also possible to use
these impls to write backend agnostic implementations.
Fixesdiesel-rs#1365.
0 commit comments