diff --git a/src/async_resolver/server_state.rs b/src/async_resolver/server_state.rs index 88608792..237503e6 100644 --- a/src/async_resolver/server_state.rs +++ b/src/async_resolver/server_state.rs @@ -6,6 +6,7 @@ use crate::async_resolver::server_entry::ServerEntry; /// A structure which describes the name servers which the resolver is /// currently trying to query. This structure keeps track of the state of a /// request if it must wait for answers from other name servers. +#[derive(Clone)] pub struct ServerState { servers: Vec, current_server_index: usize, @@ -36,10 +37,10 @@ impl ServerState { self.current_server_index = (self.current_server_index + 1)%(self.servers.len()); } - /// Returns a refererece to the current `ServerInfo` of the request. - pub fn get_current_server(&self) -> &ServerInfo { - return &self.servers[self.current_server_index].get_info(); - } + // /// Returns a refererece to the current `ServerInfo` of the request. + // pub fn get_current_server(&self) -> &ServerInfo { + // return &self.servers[self.current_server_index].get_info(); + // } pub fn get_current_server_entry(&mut self) -> &mut ServerEntry { &mut self.servers[self.current_server_index] diff --git a/src/async_resolver/state_block.rs b/src/async_resolver/state_block.rs index 76f26452..39940c04 100644 --- a/src/async_resolver/state_block.rs +++ b/src/async_resolver/state_block.rs @@ -13,6 +13,7 @@ use super::server_info::ServerInfo; /// /// The key algorithm uses the state information of the request to select the /// next name server address to query. +#[derive(Clone)] pub struct StateBlock { /// A timestamp indicating the time the request began. /// @@ -28,7 +29,7 @@ pub struct StateBlock { /// be decremented each time the resolver performs work on behalf of /// the request. If the counter reaches zero, the resolver must /// return a response to the client. - work_counter: u32, + work_counter: u16, server_state: ServerState, } @@ -43,7 +44,7 @@ impl StateBlock { /// ``` /// let state_block = StateBlock::new(Instant::now()); /// ``` - pub fn new(request_global_limit: u32, servers: Vec) -> StateBlock { + pub fn new(request_global_limit: u16, servers: Vec) -> StateBlock { StateBlock { timestamp: Instant::now(), work_counter: request_global_limit, @@ -74,11 +75,11 @@ impl StateBlock { } /// Returns a the `work_counter` of the request. - pub fn get_work_counter(&self) -> u32 { + pub fn get_work_counter(&self) -> u16 { return self.work_counter; } - pub fn get_server_state(&self) -> &ServerState { - &self.server_state + pub fn get_server_state(&mut self) -> &mut ServerState { + &mut self.server_state } } \ No newline at end of file