Skip to main content

Bind

Trait Bind 

Source
pub trait Bind:
    ToValue
    + FromValue
    + Send
    + 'static { }
Expand description

What a column’s Rust type must be able to do: bind in (ToValue) and read back out (FromValue).

This is the contract a code-generation column override hangs on. Blanket over core’s pair — deliberately not a third trait vocabulary: ToValue / FromValue are already the two halves, docs/type-mappings.md already defines their semantics per type, and the contract is defined against Value rather than any driver — so an override type binds on every backend or on none.

Generated code names this bound explicitly per overridden column type — const _: () = keelson_exec::assert_bind::<UserId>(); — so a non-binding override fails to compile in one line naming the type, not in an inference swamp.

The message that line produces is keelson’s own, not the compiler’s default walk through the blanket impl: do_not_recommend stops rustc from re-reporting the failure as two unsatisfied supertrait bounds, and on_unimplemented says the useful thing instead. That is worth an attribute on two counts — the default said ToValue is not implemented twice, with a list of unrelated types that happened to implement it, and the list’s contents drift with the compiler version (which is a failing UI test on the next release, for no change in this crate).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T: ToValue + FromValue + Send + 'static> Bind for T