This is an automated email from the ASF dual-hosted git repository.

spetz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iggy-website.git


The following commit(s) were added to refs/heads/main by this push:
     new b687c90a fix(docs): make the Rust SDK quickstart compile and run 
(closes #54) (#55)
b687c90a is described below

commit b687c90aa668c3187ddfb3d8c3d42b56d84c5de1
Author: Justin Mclean <[email protected]>
AuthorDate: Wed Aug 5 17:45:13 2026 +1000

    fix(docs): make the Rust SDK quickstart compile and run (closes #54) (#55)
---
 content/docs/sdk/rust/intro.mdx | 75 ++++++++++++++++++++++++-----------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/content/docs/sdk/rust/intro.mdx b/content/docs/sdk/rust/intro.mdx
index f7e63f01..13182d08 100644
--- a/content/docs/sdk/rust/intro.mdx
+++ b/content/docs/sdk/rust/intro.mdx
@@ -63,43 +63,56 @@ iggy://iggypat-your-token@localhost:8090
 
 ```rust
 use iggy::prelude::*;
+use std::str::FromStr;
 
 #[tokio::main]
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
-    let client = 
IggyClient::from_connection_string("iggy://iggy:iggy@localhost:8090")?;
+    let client = 
IggyClient::from_connection_string("iggy://iggy:[email protected]:8090")?;
     client.connect().await?;
 
-    // Create stream and topic
-    client.create_stream("my-stream").await?;
-    client.create_topic(
-        &"my-stream".try_into()?,
-        "my-topic",
-        2,
-        CompressionAlgorithm::None,
-        None,
-        IggyExpiry::NeverExpire,
-        MaxTopicSize::ServerDefault,
-    ).await?;
-
-    // Send a message
+    // Re-running this example is fine: an existing stream or topic is not an 
error.
+    match client.create_stream("my-stream").await {
+        Ok(_) | Err(IggyError::StreamNameAlreadyExists(_)) => {}
+        Err(e) => return Err(e.into()),
+    }
+    match client
+        .create_topic(
+            &"my-stream".try_into()?,
+            "my-topic",
+            1,
+            CompressionAlgorithm::None,
+            None,
+            IggyExpiry::NeverExpire,
+            MaxTopicSize::ServerDefault,
+        )
+        .await
+    {
+        Ok(_) | Err(IggyError::TopicNameAlreadyExists(_, _)) => {}
+        Err(e) => return Err(e.into()),
+    }
+
     let msg = IggyMessage::from_str("hello world")?;
-    client.send_messages(
-        &"my-stream".try_into()?,
-        &"my-topic".try_into()?,
-        &Partitioning::balanced(),
-        &mut [msg],
-    ).await?;
-
-    // Poll messages
-    let polled = client.poll_messages(
-        &"my-stream".try_into()?,
-        &"my-topic".try_into()?,
-        Some(1),
-        &Consumer::default(),
-        &PollingStrategy::offset(0),
-        10,
-        false,
-    ).await?;
+    client
+        .send_messages(
+            &"my-stream".try_into()?,
+            &"my-topic".try_into()?,
+            &Partitioning::partition_id(0),
+            &mut [msg],
+        )
+        .await?;
+    println!("Message sent");
+
+    let polled = client
+        .poll_messages(
+            &"my-stream".try_into()?,
+            &"my-topic".try_into()?,
+            Some(0),
+            &Consumer::default(),
+            &PollingStrategy::next(),
+            10,
+            true,
+        )
+        .await?;
 
     for message in &polled.messages {
         let payload = std::str::from_utf8(&message.payload)?;

Reply via email to