Repository: diesel-rs/diesel
File: diesel/src/query_builder/bind_collector.rs (Rust)

Code before:
        metadata_lookup: &mut DB::MetadataLookup,
    ) -> QueryResult<()>
    where
        DB: Backend + HasSqlType<T>,
        U: ToSql<T, DB> + ?Sized + 'a;

    /// Push a null value with the given type information onto the bind collector
    ///
    // For backward compatibility reasons we provide a default implementation
    // but custom backends that want to support `#[derive(MultiConnection)]`
    // need to provide a customized implementation of this function
    #[diesel_derives::__diesel_public_if(
        feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
    )]
    fn push_null_value(&mut self, _metadata: DB::TypeMetadata) -> QueryResult<()> {
        Ok(())
    }
}

/// Bind data from a BindCollector, that can be moved across threads
pub trait MoveableBindData: Send + 'static {}

/// A movable version of the bind collector which allows it to be extracted, moved and refilled.
///
/// This is mostly useful in async context where bind data needs to be moved across threads.
pub trait MoveableBindCollector<DB: TypeMetadata> {
    /// The movable bind data of this bind collector
    type BindData: MoveableBindData;

    /// Builds a movable version of the bind collector
    fn moveable(&self) -> Self::BindData;

    /// Refill the bind collector with its bind data
    fn fill_bind_data(&mut self, from: &Self::BindData);
}

#[derive(Debug)]
/// A bind collector used by backends which transmit bind parameters as an
/// opaque blob of bytes.
///
/// For most backends, this is the concrete implementation of `BindCollector`
/// that should be used.
#[diesel_derives::__diesel_public_if(
    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
    public_fields(metadata, binds)
)]
pub struct RawBytesBindCollector<DB: Backend + TypeMetadata> {
    /// The metadata associated with each bind parameter.
    ///
    /// This vec is guaranteed to be the same length as `binds`.
    pub(crate) metadata: Vec<DB::TypeMetadata>,

Review comment (suggestion):
I would like to gate that behind the `i-implement-a-third-party-backend-and-opt-into-breaking-changes` feature, as it's not useful for anyone outside of diesel-async/other crates doing really low level stuff.

Code after:
        metadata_lookup: &mut DB::MetadataLookup,
    ) -> QueryResult<()>
    where
        DB: Backend + HasSqlType<T>,
        U: ToSql<T, DB> + ?Sized + 'a;

    /// Push a null value with the given type information onto the bind collector
    ///
    // For backward compatibility reasons we provide a default implementation
    // but custom backends that want to support `#[derive(MultiConnection)]`
    // need to provide a customized implementation of this function
    #[diesel_derives::__diesel_public_if(
        feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
    )]
    fn push_null_value(&mut self, _metadata: DB::TypeMetadata) -> QueryResult<()> {
        Ok(())
    }
}

/// A movable version of the bind collector which allows it to be extracted, moved and refilled.
///
/// This is mostly useful in async context where bind data needs to be moved across threads.
#[diesel_derives::__diesel_public_if(
    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub trait MoveableBindCollector<DB: TypeMetadata> {
    /// The movable bind data of this bind collector
    type BindData: Send + 'static;

    /// Builds a movable version of the bind collector
    fn moveable(&self) -> Self::BindData;

    /// Refill the bind collector with its bind data
    fn append_bind_data(&mut self, from: &Self::BindData);
}

#[derive(Debug)]
/// A bind collector used by backends which transmit bind parameters as an
/// opaque blob of bytes.
///
/// For most backends, this is the concrete implementation of `BindCollector`
/// that should be used.
#[diesel_derives::__diesel_public_if(
    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
    public_fields(metadata, binds)
)]
pub struct RawBytesBindCollector<DB: Backend + TypeMetadata> {
    /// The metadata associated with each bind parameter.
    ///
    /// This vec is guaranteed to be the same length as `binds`.
    pub(crate) metadata: Vec<DB::TypeMetadata>,