Skip to content

Commit

Permalink
Fix named ID on the client (#1455)
Browse files Browse the repository at this point in the history
This fixes #1456 by ensuring that the named `Identifier` will be set
correctly on the client-side. In the future, we might allow the user to
provide any name without the additional conversion, case-invariant
checks etc.
  • Loading branch information
spetz authored Jan 23, 2025
1 parent 5f2a435 commit c316714
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iggy"
version = "0.6.80"
version = "0.6.81"
description = "Iggy is the persistent message streaming platform written in Rust, supporting QUIC, TCP and HTTP transport protocols, capable of processing millions of messages per second."
edition = "2021"
license = "Apache-2.0"
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::bytes_serializable::BytesSerializable;
use crate::error::IggyError;
use crate::utils::byte_size::IggyByteSize;
use crate::utils::sizeable::Sizeable;
use crate::utils::text::to_lowercase_non_whitespace;
use crate::validatable::Validatable;
use bytes::{BufMut, Bytes, BytesMut};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -150,13 +151,14 @@ impl Identifier {
})
}

/// Creates a new identifier from the given string value. The name will be always converted to lowercase and all whitespaces will be replaced with dots.
/// Creates a new identifier from the given string value. The name will always be converted to lowercase and all whitespaces will be replaced with dots.
pub fn named(value: &str) -> Result<Self, IggyError> {
let length = value.len();
if length == 0 || length > 255 {
return Err(IggyError::InvalidIdentifier);
}

let value = to_lowercase_non_whitespace(value);
Ok(Self {
kind: IdKind::String,
#[allow(clippy::cast_possible_truncation)]
Expand Down

0 comments on commit c316714

Please sign in to comment.