Skip to content

Commit 1376a7c

Browse files
committed
refactor: [#1446] rename AddressType to IpType
Address might be a socket address.
1 parent 476ece4 commit 1376a7c

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

packages/http-tracker-core/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ impl From<ConnectionContext> for LabelSet {
8787
LabelValue::new(&connection_context.server.service_binding.bind_address().ip().to_string()),
8888
),
8989
(
90-
label_name!("server_binding_address_type"),
91-
LabelValue::new(&connection_context.server.service_binding.bind_address_type().to_string()),
90+
label_name!("server_binding_address_ip_type"),
91+
LabelValue::new(&connection_context.server.service_binding.bind_address_ip_type().to_string()),
9292
),
9393
(
9494
label_name!("server_binding_port"),

packages/primitives/src/service_binding.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl fmt::Display for Protocol {
2626
}
2727

2828
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
29-
pub enum AddressType {
29+
pub enum IpType {
3030
/// Represents a plain IPv4 or IPv6 address.
3131
Plain,
3232

@@ -38,7 +38,7 @@ pub enum AddressType {
3838
V4MappedV6,
3939
}
4040

41-
impl fmt::Display for AddressType {
41+
impl fmt::Display for IpType {
4242
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4343
let addr_type_str = match self {
4444
Self::Plain => "plain",
@@ -120,12 +120,12 @@ impl ServiceBinding {
120120
}
121121

122122
#[must_use]
123-
pub fn bind_address_type(&self) -> AddressType {
123+
pub fn bind_address_ip_type(&self) -> IpType {
124124
if self.is_v4_mapped_v6() {
125-
return AddressType::V4MappedV6;
125+
return IpType::V4MappedV6;
126126
}
127127

128-
AddressType::Plain
128+
IpType::Plain
129129
}
130130

131131
/// # Panics
@@ -169,7 +169,7 @@ mod tests {
169169
use rstest::rstest;
170170
use url::Url;
171171

172-
use crate::service_binding::{AddressType, Error, Protocol, ServiceBinding};
172+
use crate::service_binding::{Error, IpType, Protocol, ServiceBinding};
173173

174174
#[rstest]
175175
#[case("wildcard_ip", Protocol::UDP, SocketAddr::from_str("0.0.0.0:6969").unwrap())]
@@ -203,23 +203,23 @@ mod tests {
203203
fn should_return_the_bind_address_plain_type_for_ipv4_ips() {
204204
let service_binding = ServiceBinding::new(Protocol::UDP, SocketAddr::from_str("127.0.0.1:6969").unwrap()).unwrap();
205205

206-
assert_eq!(service_binding.bind_address_type(), AddressType::Plain);
206+
assert_eq!(service_binding.bind_address_ip_type(), IpType::Plain);
207207
}
208208

209209
#[test]
210210
fn should_return_the_bind_address_plain_type_for_ipv6_ips() {
211211
let service_binding =
212212
ServiceBinding::new(Protocol::UDP, SocketAddr::from_str("[0:0:0:0:0:0:0:1]:6969").unwrap()).unwrap();
213213

214-
assert_eq!(service_binding.bind_address_type(), AddressType::Plain);
214+
assert_eq!(service_binding.bind_address_ip_type(), IpType::Plain);
215215
}
216216

217217
#[test]
218218
fn should_return_the_bind_address_v4_mapped_v7_type_for_ipv4_ips_mapped_to_ipv6() {
219219
let service_binding =
220220
ServiceBinding::new(Protocol::UDP, SocketAddr::from_str("[::ffff:192.0.2.33]:6969").unwrap()).unwrap();
221221

222-
assert_eq!(service_binding.bind_address_type(), AddressType::V4MappedV6);
222+
assert_eq!(service_binding.bind_address_ip_type(), IpType::V4MappedV6);
223223
}
224224

225225
#[test]

packages/udp-tracker-core/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl From<ConnectionContext> for LabelSet {
6060
LabelValue::new(&connection_context.server_service_binding.bind_address().ip().to_string()),
6161
),
6262
(
63-
label_name!("server_binding_address_type"),
64-
LabelValue::new(&connection_context.server_service_binding.bind_address_type().to_string()),
63+
label_name!("server_binding_address_ip_type"),
64+
LabelValue::new(&connection_context.server_service_binding.bind_address_ip_type().to_string()),
6565
),
6666
(
6767
label_name!("server_binding_port"),

packages/udp-tracker-server/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ impl From<ConnectionContext> for LabelSet {
119119
LabelValue::new(&connection_context.server_service_binding.bind_address().ip().to_string()),
120120
),
121121
(
122-
label_name!("server_binding_address_type"),
123-
LabelValue::new(&connection_context.server_service_binding.bind_address_type().to_string()),
122+
label_name!("server_binding_address_ip_type"),
123+
LabelValue::new(&connection_context.server_service_binding.bind_address_ip_type().to_string()),
124124
),
125125
(
126126
label_name!("server_binding_port"),

0 commit comments

Comments
 (0)