Struct ctf_tcp_utils::TcpHandler
source · pub struct TcpHandler { /* private fields */ }
Implementations§
source§impl TcpHandler
impl TcpHandler
sourcepub fn new(server_url: &str, port: u16) -> Result<Self, CtfTcpHandlerError>
pub fn new(server_url: &str, port: u16) -> Result<Self, CtfTcpHandlerError>
Create a new TcpHandler
wit a default 1s read timeout.
Errors
May fail if server:port is unavaible or read timeout cannot be set.
sourcepub fn read_to_string(&mut self) -> String
pub fn read_to_string(&mut self) -> String
Read TCP stream until read timeout is reached. Always produces a String using UTF-8 lossy conversion.
sourcepub fn write_answer(&mut self, answer: &str)
pub fn write_answer(&mut self, answer: &str)
Read TCP stream until read timeout is reached. Always produces a String using UTF-8 lossy conversion.
sourcepub fn set_timeout(&mut self, timeout: u64) -> Result<(), CtfTcpHandlerError>
pub fn set_timeout(&mut self, timeout: u64) -> Result<(), CtfTcpHandlerError>
Set read timeout.
timeout are milliseconds, given with a u64
Errors
Fail if read timeout cannot be set.
Auto Trait Implementations§
impl RefUnwindSafe for TcpHandler
impl Send for TcpHandler
impl Sync for TcpHandler
impl Unpin for TcpHandler
impl UnwindSafe for TcpHandler
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more