pub struct Server { /* private fields */ }Expand description
Sans-IO Kermit server. See the module documentation.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(config: ServerConfig) -> Self
pub fn new(config: ServerConfig) -> Self
New server, waiting for the client’s first packet.
Sourcepub fn params(&self) -> InitParams
pub fn params(&self) -> InitParams
Our Send-Init parameters (what we answer an I or S with).
Sourcepub fn handle_input(&mut self, now: Instant, bytes: &[u8])
pub fn handle_input(&mut self, now: Instant, bytes: &[u8])
Feed bytes read from the link.
Sourcepub fn handle_timeout(&mut self, now: Instant)
pub fn handle_timeout(&mut self, now: Instant)
Call when the time from Server::next_timeout has passed.
Sourcepub fn poll_output(&mut self, now: Instant) -> Option<Vec<u8>>
pub fn poll_output(&mut self, now: Instant) -> Option<Vec<u8>>
Next packet to write (one whole packet, as the client’s). None if
nothing is due at now.
Sourcepub fn poll_event(&mut self) -> Option<ServerEvent>
pub fn poll_event(&mut self) -> Option<ServerEvent>
Next event, in order.
Sourcepub fn next_timeout(&self) -> Option<Instant>
pub fn next_timeout(&self) -> Option<Instant>
When the server wants to be called again: a queued packet becomes
due, or the client’s next packet is late. None between
transactions: the server waits for the client as long as it takes.
Sourcepub fn is_requested(&self) -> bool
pub fn is_requested(&self) -> bool
A request (ServerEvent::Request) waits for Server::serve or
Server::refuse.
Sourcepub fn serve(
&mut self,
now: Instant,
file: OutgoingFile,
) -> Result<(), NoRequest>
pub fn serve( &mut self, now: Instant, file: OutgoingFile, ) -> Result<(), NoRequest>
Answer the waiting request with file: S, F, D.., Z, B. The F
carries file.name.
Sourcepub fn refuse(&mut self, now: Instant, text: &[u8]) -> Result<(), NoRequest>
pub fn refuse(&mut self, now: Instant, text: &[u8]) -> Result<(), NoRequest>
Refuse the waiting request with an E packet carrying text (e.g.
“File not found”). The calculator answers with its own E, which
comes as ServerEvent::Remote.
Sourcepub fn reject(&mut self, now: Instant, text: &[u8]) -> Result<(), NoRequest>
pub fn reject(&mut self, now: Instant, text: &[u8]) -> Result<(), NoRequest>
Refuse the file being received, right after its
ServerEvent::FileStart: an E packet carrying text (in place of
the ACK to the F if that is not written yet) and
ServerEvent::Error (Error::Cancelled). Refused when no file
is being received.
Sourcepub fn cancel(&mut self, now: Instant)
pub fn cancel(&mut self, now: Instant)
Abort a running transaction with an E packet “Cancelled” and
ServerEvent::Error (Error::Cancelled); a waiting request is
refused the same way. Nothing between transactions.