feat(client): add configuration validation and new error types

This commit is contained in:
Nils Andreas Svee committed 2026-05-10 20:56:43 +07:00
1 parent 265618b97e
commit cdf41f2a82
2 files changed
+12

No files matched your search

+10
View File
@@ -40,6 +40,16 @@ pub struct Client {
impl Client {
pub fn connect(config: ClientConfig) -> Result<Self, ClientError> {
validate_open_timeouts(&config.open_timeouts)?;
if config.max_pending_probes == 0 {
return Err(ClientError::InvalidConfig {
reason: "max_pending_probes must be greater than zero".to_owned(),
});
}
if config.probe_timeout == Duration::ZERO {
return Err(ClientError::InvalidConfig {
reason: "probe_timeout must be greater than zero".to_owned(),
});
}
let remote = resolve_remote(&config)?;
let socket = connect_udp_socket(&config.socket_config, remote)?;
let requested = params_from_config(&config)?;