use crate::pmimetype::PMimeType;
#[derive(Debug, Default)]
pub struct PRequestParam {
command: String,
url: String,
protocol: String,
}
impl PRequestParam {
pub fn set_command(&mut self, command: &String) {
self.command = command.to_string();
}
pub fn set_url(&mut self, url: &String) {
self.url = url.to_string();
}
pub fn set_protocol(&mut self, protocol: &String) {
self.protocol = protocol.to_string();
}
pub fn get_url(&self) -> &String {
&self.url
}
pub fn get_command(&self) -> &String {
&self.command
}
pub fn get_protocol(&self) -> &String {
&self.protocol
}
}
#[derive(Debug, Default)]
pub struct PResponseParam {
pub status: String,
pub mimetype: PMimeType,
pub content: String,
}
impl PResponseParam {
pub fn new(status: String, mimetype: PMimeType, content: &String) -> Self{
PResponseParam {
status: status,
mimetype: mimetype,
content: content.to_owned()
}
}
pub fn set_status(&mut self, status: &String) {
self.status = status.to_string();
}
pub fn set_content(&mut self, content: &String) {
self.content = content.to_string();
}
pub fn set_mime_type(&mut self, mimetype: &PMimeType){
self.mimetype = *mimetype;
}
}
pub trait PhoenixRequestStream {
fn recv_request(&mut self, request: &mut PRequestParam) -> bool;
fn send_response(&mut self, response: &PResponseParam);
}
pub trait PhoenixRequestMockStream {
fn set_is_record(&mut self, is_mock_record: bool);
fn set_prefix(&mut self, prefix: &String);
}
pub trait PhoenixRequestServer {
type Stream;
fn new(hostname: &String, port: u16) -> Self;
fn accept(&self) -> Self::Stream;
}
pub trait PhoenixRequestMockServer {
fn set_is_record(&mut self, is_mock_record: bool);
fn set_prefix(&mut self, prefix: &String);
}