use super::{Responder, ResponderInner, SuccessResponse};
use std::net::IpAddr;
use std::sync::Arc;
#[derive(Debug, Clone, Default)]
pub struct SuccessResponseBuilder {
response: SuccessResponse,
}
impl SuccessResponseBuilder {
pub fn with_external_ip(mut self, ip: IpAddr) -> Self {
self.response.external_ip = Some(ip);
self
}
pub fn with_connection_status(mut self, status: impl Into<String>) -> Self {
self.response.connection_status = Some(status.into());
self
}
pub fn with_last_connection_error(mut self, error: impl Into<String>) -> Self {
self.response.last_connection_error = Some(error.into());
self
}
pub fn with_uptime(mut self, uptime: u32) -> Self {
self.response.uptime = Some(uptime);
self
}
pub fn with_remote_host(mut self, host: impl Into<String>) -> Self {
self.response.remote_host = Some(host.into());
self
}
pub fn with_external_port(mut self, port: u16) -> Self {
self.response.external_port = Some(port);
self
}
pub fn with_protocol(mut self, protocol: impl Into<String>) -> Self {
self.response.protocol = Some(protocol.into());
self
}
pub fn with_internal_port(mut self, port: u16) -> Self {
self.response.internal_port = Some(port);
self
}
pub fn with_internal_client(mut self, client: impl Into<String>) -> Self {
self.response.internal_client = Some(client.into());
self
}
pub fn with_enabled(mut self, enabled: bool) -> Self {
self.response.enabled = Some(enabled);
self
}
pub fn with_description(mut self, description: impl Into<String>) -> Self {
self.response.description = Some(description.into());
self
}
pub fn with_lease_duration(mut self, duration: u32) -> Self {
self.response.lease_duration = Some(duration);
self
}
pub fn with_wan_access_type(mut self, access_type: impl Into<String>) -> Self {
self.response.wan_access_type = Some(access_type.into());
self
}
pub fn with_layer1_upstream_max_bit_rate(mut self, rate: u32) -> Self {
self.response.layer1_upstream_max_bit_rate = Some(rate);
self
}
pub fn with_layer1_downstream_max_bit_rate(mut self, rate: u32) -> Self {
self.response.layer1_downstream_max_bit_rate = Some(rate);
self
}
pub fn with_physical_link_status(mut self, status: impl Into<String>) -> Self {
self.response.physical_link_status = Some(status.into());
self
}
pub fn with_total_bytes(mut self, bytes: u64) -> Self {
self.response.total_bytes = Some(bytes);
self
}
pub fn build(self) -> Responder {
Responder {
inner: Arc::new(ResponderInner::Success(self.response)),
}
}
}
impl From<SuccessResponseBuilder> for Responder {
fn from(builder: SuccessResponseBuilder) -> Self {
builder.build()
}
}