Skip to main content

is_valid_client_info

Function is_valid_client_info 

Source
pub fn is_valid_client_info(s: &str) -> bool
Expand description

KIP-511 client-information validity check. Matches the JVM ApiVersionsRequest.isValid regex [a-zA-Z0-9](?:[a-zA-Z0-9\-.]*[a-zA-Z0-9])?:

  • non-empty
  • first and last chars are [a-zA-Z0-9]
  • interior chars are [a-zA-Z0-9\-.]

A single alphanumeric char is valid, because the optional middle group lets the first and last char coincide.

The check is a byte scan instead of a regex dependency. Every Kafka-client name in use stays within ASCII, so full UTF-8 char-class semantics are not needed.