pub struct UdpTrackerConfig { /* private fields */ }Expand description
UDP tracker bind configuration with domain invariants enforced at construction
This type guarantees that any instance is valid according to domain rules:
- Bind address has a non-zero port
Note: Unlike HTTP trackers, UDP does not support TLS, so there are no TLS-related validation rules.
§Construction
Use UdpTrackerConfig::new() to create instances with validation:
use torrust_tracker_deployer_lib::domain::tracker::UdpTrackerConfig;
let config = UdpTrackerConfig::new(
"0.0.0.0:6969".parse().unwrap(),
None,
)?;§Invariants
The following invariants are enforced at construction time:
- No dynamic ports:
bind_address.port() != 0
Implementations§
Source§impl UdpTrackerConfig
impl UdpTrackerConfig
Sourcepub fn new(
bind_address: SocketAddr,
domain: Option<DomainName>,
) -> Result<Self, UdpTrackerConfigError>
pub fn new( bind_address: SocketAddr, domain: Option<DomainName>, ) -> Result<Self, UdpTrackerConfigError>
Creates a new UDP tracker configuration with validation
This is the primary way to construct a UdpTrackerConfig. All domain
invariants are validated before the instance is created.
§Arguments
bind_address- Socket address to bind to (e.g., “0.0.0.0:6969”)domain- Optional domain for announce URLs
§Errors
Returns UdpTrackerConfigError if any invariant is violated:
DynamicPortNotSupported- if port is 0
§Examples
use torrust_tracker_deployer_lib::domain::tracker::UdpTrackerConfig;
use torrust_tracker_deployer_lib::shared::DomainName;
// Basic configuration without domain
let config = UdpTrackerConfig::new(
"0.0.0.0:6969".parse().unwrap(),
None,
)?;
// Configuration with domain
let config_with_domain = UdpTrackerConfig::new(
"0.0.0.0:6969".parse().unwrap(),
Some(DomainName::new("tracker.example.com")?),
)?;Sourcepub fn bind_address(&self) -> SocketAddr
pub fn bind_address(&self) -> SocketAddr
Returns the bind address
Sourcepub fn domain(&self) -> Option<&DomainName>
pub fn domain(&self) -> Option<&DomainName>
Returns a reference to the domain, if configured
Trait Implementations§
Source§impl Clone for UdpTrackerConfig
impl Clone for UdpTrackerConfig
Source§impl Debug for UdpTrackerConfig
impl Debug for UdpTrackerConfig
Source§impl<'de> Deserialize<'de> for UdpTrackerConfig
Enables deserialization with validation through the constructor
impl<'de> Deserialize<'de> for UdpTrackerConfig
Enables deserialization with validation through the constructor
This ensures that JSON deserialization also validates the config, maintaining the “always valid” invariant even for loaded data.
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for UdpTrackerConfig
impl Display for UdpTrackerConfig
Source§impl PartialEq for UdpTrackerConfig
impl PartialEq for UdpTrackerConfig
Source§impl Serialize for UdpTrackerConfig
impl Serialize for UdpTrackerConfig
impl StructuralPartialEq for UdpTrackerConfig
Source§impl TryFrom<UdpTrackerSection> for UdpTrackerConfig
Converts from application DTO to domain type using TryFrom trait
impl TryFrom<UdpTrackerSection> for UdpTrackerConfig
Converts from application DTO to domain type using TryFrom trait
This implementation follows the standard library convention for fallible
conversions, enabling use of .try_into() and TryFrom::try_from().
§Example
let section = UdpTrackerSection { bind_address: "0.0.0.0:6969".to_string(), domain: None };
let config: UdpTrackerConfig = section.try_into()?;Source§type Error = CreateConfigError
type Error = CreateConfigError
Auto Trait Implementations§
impl Freeze for UdpTrackerConfig
impl RefUnwindSafe for UdpTrackerConfig
impl Send for UdpTrackerConfig
impl Sync for UdpTrackerConfig
impl Unpin for UdpTrackerConfig
impl UnsafeUnpin for UdpTrackerConfig
impl UnwindSafe for UdpTrackerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = !
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.