diff --git a/Cargo.toml b/Cargo.toml index 642eef9..5c06dd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiny_kafka" -version = "1.0.1" +version = "1.0.2" authors = ["Christos Ploutarchou "] edition = "2021" description = "A tiny Kafka client library with producer and consumer functionalities." diff --git a/src/consumer.rs b/src/consumer.rs index d33bb64..c43870e 100644 --- a/src/consumer.rs +++ b/src/consumer.rs @@ -25,6 +25,7 @@ pub struct ReceivedMessage { /// /// ```no_run /// use std::collections::HashMap; +/// use tiny_kafka::consumer::KafkaConsumer; /// let mut consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic"); /// /// // Consume messages in a loop @@ -61,6 +62,7 @@ impl KafkaConsumer { /// Basic usage: /// /// ```no_run + /// use tiny_kafka::consumer::KafkaConsumer; /// let consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic"); /// ``` pub fn new(brokers: &str, group_id: &str, topic_name: &str) -> Self { @@ -94,6 +96,7 @@ impl KafkaConsumer { /// Basic usage: /// /// ```no_run + /// use tiny_kafka::consumer::KafkaConsumer; /// tokio::spawn(async move { /// let consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic"); /// if let Some(msg) = consumer.poll().await { @@ -155,6 +158,7 @@ impl KafkaConsumer { /// /// ```no_run /// use std::collections::HashMap; + /// use tiny_kafka::consumer::KafkaConsumer; /// let mut consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic"); /// let mut new_configs = HashMap::new(); /// new_configs.insert("auto.offset.reset".to_string(), "earliest".to_string()); diff --git a/src/producer.rs b/src/producer.rs index da0e903..aff06db 100644 --- a/src/producer.rs +++ b/src/producer.rs @@ -11,8 +11,8 @@ use std::time::Duration; /// Represents a message with a key and value to be sent to Kafka. #[derive(Serialize)] pub struct Message { - key: String, - value: String, + pub key: String, + pub value: String, } impl Message { @@ -25,6 +25,7 @@ impl Message { /// # Examples /// /// ``` + /// use tiny_kafka::producer::Message; /// let msg = Message::new("key1", "value1"); /// assert_eq!(msg.key, "key1"); /// assert_eq!(msg.value, "value1"); @@ -53,6 +54,8 @@ impl KafkaProducer { /// /// ```no_run /// // Initialize a KafkaProducer without any custom configurations + /// use std::collections::HashMap; + /// use tiny_kafka::producer::KafkaProducer; /// let producer = KafkaProducer::new("localhost:9092", None); /// /// // With custom configurations @@ -90,6 +93,7 @@ impl KafkaProducer { /// # Examples /// /// ```no_run + /// use tiny_kafka::producer::{KafkaProducer, Message}; /// let producer = KafkaProducer::new("localhost:9092", None); /// let msg = Message::new("key1", "value1"); /// @@ -137,6 +141,8 @@ impl KafkaProducer { /// # Examples /// /// ```no_run + /// use std::collections::HashMap; + /// use tiny_kafka::producer::KafkaProducer; /// let mut producer = KafkaProducer::new("localhost:9092", None); /// /// // Update producer configurations