Skip to content

Commit

Permalink
add: server state struct
Browse files Browse the repository at this point in the history
  • Loading branch information
justRkive committed Aug 6, 2024
1 parent 95b5781 commit b002c2b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod resolver_error;
pub mod server_info;
pub mod slist;
pub mod state_block;
pub mod server_state;

use self::lookup_response::LookupResponse;
use crate::async_resolver::resolver_error::ResolverError;
Expand Down
35 changes: 35 additions & 0 deletions src/async_resolver/server_state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use crate::async_resolver::server_info::ServerInfo;

/// Struct that holds the state of the queried server for a single request.
///
/// 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.
pub struct ServerState {
name_servers: Vec<ServerInfo>,
current_server_index: usize,
}

impl ServerState {
/// Creates a new ServerState for a request.
///
/// # Arguments
/// * `name_servers` - A vector of ServerInfo structs that represent the name servers to query.
///
/// # Example
/// ```
/// let server_state = ServerState::new(vec![ServerInfo::new("
///
/// ```
pub fn new(name_servers: Vec<ServerInfo>) -> ServerState {
ServerState {
name_servers: name_servers,
current_server_index: 0,
}
}

/// Returns a reference to the `name_servers` of the request.
pub fn get_name_servers(&self) -> &Vec<ServerInfo> {
return &self.name_servers;
}
}

0 comments on commit b002c2b

Please sign in to comment.