Skip to main content

validate_endpoint_for_aeron_udp

Function validate_endpoint_for_aeron_udp 

Source
pub fn validate_endpoint_for_aeron_udp(
    endpoint: &str,
) -> Result<(), AeronCError>
Expand description

Validate a UDP channel URI endpoint (host:port) for use with Aeron.

This validates the shape and character set of endpoint strings passed to AeronUriStringBuilder::endpoint or used directly in channel URIs like aeron:udp?endpoint=localhost:40123. Aeron does not validate input upfront; this function catches malformed endpoints before they reach the C layer, providing clearer error messages than the generic C parse failures.

§Accepted forms

  • hostname:port — host is alphanumeric plus - and ., port 0-65535
  • IPv4:port — dotted decimal, port 0-65535
  • [IPv6]:port — bracketed IPv6 literal, port required

§Errors

Returns Err(AeronCError) with code -1 for any validation failure:

  • empty string or missing port separator
  • port not 0..=65535 or not a decimal integer
  • host contains characters outside the safe allowlist (alphanumeric, -, ., : for IPv4, [] for IPv6 bracketing)
  • URI separator characters (?, =, :, /) appear unescaped

§Example

// (illustrative — `aeron_custom.rs` is `include!`'d into multiple crates, so
//  no single `use` path compiles across all of them; see the
//  `aeron_custom_tests` module for runnable pure-Rust assertions)
assert!(validate_endpoint_for_aeron_udp("localhost:40123").is_ok());
assert!(validate_endpoint_for_aeron_udp("[::1]:40123").is_ok());
assert!(validate_endpoint_for_aeron_udp("localhost:99999").is_err());
assert!(validate_endpoint_for_aeron_udp("localhost?foo:8080").is_err());