pub struct MockProducerOptionsBuilder<K, V> { /* private fields */ }Expand description
Fluent builder for MockProducerOptions.
Self::new takes no parameters, every parameter has a fluent setter, and
Self::build validates the mandatory ones — returning
Error::LocalIllegalArgument if they were not set. Like
MockProducerOptions it has no Java counterpart.
Implementations§
Source§impl<K, V> MockProducerOptionsBuilder<K, V>
impl<K, V> MockProducerOptionsBuilder<K, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder with every mandatory parameter unset and every other parameter at the value Java passes on the caller’s behalf.
Sourcepub fn set_cluster(self, cluster: Cluster) -> Self
pub fn set_cluster(self, cluster: Cluster) -> Self
Sourcepub fn set_auto_complete(self, auto_complete: bool) -> Self
pub fn set_auto_complete(self, auto_complete: bool) -> Self
Sets MockProducerOptions::auto_complete, a mandatory parameter:
Self::build returns an error if it was not set.
§Arguments
auto_complete- whether to complete every request automatically
§Returns
This builder.
Sourcepub fn set_partitioner(
self,
partitioner: Option<Box<dyn Partitioner<K, V>>>,
) -> Self
pub fn set_partitioner( self, partitioner: Option<Box<dyn Partitioner<K, V>>>, ) -> Self
Sourcepub fn set_key_serializer(
self,
key_serializer: impl Serializer<K> + 'static,
) -> Self
pub fn set_key_serializer( self, key_serializer: impl Serializer<K> + 'static, ) -> Self
Sets MockProducerOptions::key_serializer, any Serializer<K>;
unset is Java’s null, which MockProducer() passes.
§Arguments
key_serializer- the serializer for key
§Returns
This builder.
Sourcepub fn set_value_serializer(
self,
value_serializer: impl Serializer<V> + 'static,
) -> Self
pub fn set_value_serializer( self, value_serializer: impl Serializer<V> + 'static, ) -> Self
Sets MockProducerOptions::value_serializer, any Serializer<V>;
unset is Java’s null.
§Arguments
value_serializer- the serializer for value
§Returns
This builder.
Sourcepub fn build(self) -> Result<MockProducerOptions<K, V>, Error>
pub fn build(self) -> Result<MockProducerOptions<K, V>, Error>
Returns the built options.
The mandatory parameters are validated here rather than being named in
the constructor, so a later Java version that makes one of them
optional changes the set this accepts instead of adding a second
constructor. Today there is one mandatory set: auto_complete. cluster
is not in it because Java’s Cluster#Cluster supplies Cluster.empty() itself.
§Errors
Error::is_local_illegal_argument_error, naming the first parameter of that set which was not given a setter call. Only presence is checked here; semantic validation belongs to the method the options are passed to.