Skip to main content

Server

Struct Server 

Source
pub struct Server { /* private fields */ }
Expand description

Sans-IO Kermit server. See the module documentation.

Implementations§

Source§

impl Server

Source

pub fn new(config: ServerConfig) -> Self

New server, waiting for the client’s first packet.

Source

pub fn params(&self) -> InitParams

Our Send-Init parameters (what we answer an I or S with).

Source

pub fn handle_input(&mut self, now: Instant, bytes: &[u8])

Feed bytes read from the link.

Source

pub fn handle_timeout(&mut self, now: Instant)

Call when the time from Server::next_timeout has passed.

Source

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.

Source

pub fn poll_event(&mut self) -> Option<ServerEvent>

Next event, in order.

Source

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.

Source

pub fn is_idle(&self) -> bool

No transaction is running and no request waits for an answer.

Source

pub fn is_requested(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Server

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Server

§

impl Freeze for Server

§

impl Move for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnsafeUnpin for Server

§

impl UnwindSafe for Server

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.