From e8463f0d0a74101e41b839c742dffc3f8689c47f Mon Sep 17 00:00:00 2001 From: Katia Fredes Date: Tue, 6 Aug 2024 19:36:58 -0400 Subject: [PATCH] add: get_current_server and increment_current_index --- src/async_resolver/server_state.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/async_resolver/server_state.rs b/src/async_resolver/server_state.rs index 1f3d3318..58b06c08 100644 --- a/src/async_resolver/server_state.rs +++ b/src/async_resolver/server_state.rs @@ -28,6 +28,18 @@ impl ServerState { } } + /// Increments the `current_server_index` of the request. + /// + /// It it used when the resolver must query the next name server in the list. + pub fn increment_current_server_index(&mut self) { + self.current_server_index = (self.current_server_index + 1)%(self.name_servers.len()); + } + + /// Returns a refererece to the current `ServerInfo` of the request. + pub fn get_current_server(&self) -> &ServerInfo { + return &self.name_servers[self.current_server_index]; + } + /// Returns a reference to the `name_servers` of the request. pub fn get_name_servers(&self) -> &Vec { return &self.name_servers;