use std::future::Future;
use crate::{errors::EasyHttpMockError, mock::Mock};
pub trait ServerAdapter {
type Config: Clone;
fn new(config: Self::Config) -> Result<Self, EasyHttpMockError>
where
Self: Sized;
fn hostname(&self) -> String;
fn base_url(&self) -> String;
fn config(&self) -> &Self::Config;
fn register_mock(&mut self, mock: Mock);
fn start(&mut self) -> impl Future<Output = Result<(), EasyHttpMockError>>;
fn stop(&mut self) -> impl Future<Output = Result<(), EasyHttpMockError>>;
}
pub trait PortGenerator<S>
where
S: ServerAdapter,
S::Config: Clone,
{
fn random_port() -> u16 {
rand::random_range(9000..65535)
}
fn with_random_port(self) -> Self;
}