pub struct NewTopic { /* private fields */ }Expand description
A new topic to be created via Admin::create_topics.
Corresponds to org.apache.kafka.clients.admin.NewTopic.
replicas_assignments and configs use BTreeMap (rather than HashMap)
so that conversion to the wire request is deterministically ordered — Java
iterates its Map in unspecified order, but a stable order simplifies
wire-byte comparison and testing.
Implementations§
Source§impl NewTopic
impl NewTopic
Sourcepub fn with_num_partitions_replication_factor(
name: impl Into<String>,
num_partitions: Option<i32>,
replication_factor: Option<i16>,
) -> Self
pub fn with_num_partitions_replication_factor( name: impl Into<String>, num_partitions: Option<i32>, replication_factor: Option<i16>, ) -> Self
A new topic with the specified replication factor and number of
partitions, either of which optionally defaults to the broker
configurations for num.partitions and default.replication.factor
respectively.
Translates both of Java’s first two constructors:
NewTopic(String, int, short) (NewTopic.java:47) and
NewTopic(String, Optional<Integer>, Optional<Short>) (:56). They
differ only by the Optional wrapper — :47’s body is literally
this(name, Optional.of(numPartitions), Optional.of(replicationFactor))
— so under CLAUDE.md §2 (“in case the difference is only Optional
use Rust’s Option and a single method name”) they are one Rust method
taking Option. Callers of the former pass Some(..).
The surviving group is {name, num_partitions, replication_factor} and
{name, replicas_assignments}, whose intersection is {name}. No
constructor takes name alone, so under §2 nobody keeps the plain
new and both carry a parameter-name suffix.
Sourcepub fn with_replicas_assignments(
name: impl Into<String>,
replicas_assignments: BTreeMap<i32, Vec<i32>>,
) -> Self
pub fn with_replicas_assignments( name: impl Into<String>, replicas_assignments: BTreeMap<i32, Vec<i32>>, ) -> Self
A new topic with the specified replica assignment configuration.
name- the topic namereplicas_assignments- a map from partition id to replica ids (i.e. broker ids). The first replica is treated as the preferred leader.
Sourcepub fn num_partitions(&self) -> i32
pub fn num_partitions(&self) -> i32
The number of partitions for the new topic or -1 if a replica assignment has been specified.
Sourcepub fn replication_factor(&self) -> i16
pub fn replication_factor(&self) -> i16
The replication factor for the new topic or -1 if a replica assignment has been specified.
Sourcepub fn replicas_assignments(&self) -> Option<&BTreeMap<i32, Vec<i32>>>
pub fn replicas_assignments(&self) -> Option<&BTreeMap<i32, Vec<i32>>>
A map from partition id to replica ids (i.e. broker ids) or None if the
number of partitions and replication factor have been specified instead.
Sourcepub fn set_configs(self, configs: BTreeMap<String, String>) -> Self
pub fn set_configs(self, configs: BTreeMap<String, String>) -> Self
Set the configuration to use on the new topic. Returns self for
chaining, mirroring Java’s fluent configs(...).
Trait Implementations§
impl Eq for NewTopic
impl StructuralPartialEq for NewTopic
Auto Trait Implementations§
impl Freeze for NewTopic
impl RefUnwindSafe for NewTopic
impl Send for NewTopic
impl Sync for NewTopic
impl Unpin for NewTopic
impl UnsafeUnpin for NewTopic
impl UnwindSafe for NewTopic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.