[][src]Struct smolapps::tftp::Server

pub struct Server { /* fields omitted */ }

TFTP server.

Implementations

impl Server[src]

pub fn new<'a, 'b, 'c>(
    sockets: &mut SocketSet<'a, 'b, 'c>,
    rx_buffer: UdpSocketBuffer<'b, 'c>,
    tx_buffer: UdpSocketBuffer<'b, 'c>,
    now: Instant
) -> Self
[src]

Creates a TFTP server.

A new socket will be allocated and added to the provided SocketSet.

Usage

use smolapps::tftp::Server;
use smolapps::net::socket::{SocketSet, UdpSocketBuffer, UdpPacketMetadata};
use smolapps::net::time::Instant;
use smolapps::net::wire::IpAddress;

let mut sockets_entries: [_; 1] = Default::default();
let mut sockets = SocketSet::new(&mut sockets_entries[..]);

let mut tftp_rx_storage: [u8; 1048] = [0; 1048];
let mut tftp_rx_metadata: [_; 2] = [UdpPacketMetadata::EMPTY; 2];

let mut tftp_tx_storage: [u8; 1048] = [0; 1048];
let mut tftp_tx_metadata: [_; 2] = [UdpPacketMetadata::EMPTY; 2];

let tftp_rx_buffer = UdpSocketBuffer::new(
    &mut tftp_rx_metadata[..],
    &mut tftp_rx_storage[..]
);
let tftp_tx_buffer = UdpSocketBuffer::new(
    &mut tftp_tx_metadata[..],
    &mut tftp_tx_storage[..],
);

let mut tftp = Server::new(
    &mut sockets,
    tftp_rx_buffer,
    tftp_tx_buffer,
    Instant::from_secs(0),
);

pub fn next_poll(&self, now: Instant) -> Duration[src]

Returns the duration until the next poll activity.

Useful for suspending execution after polling.

pub fn serve<'a, C>(
    &mut self,
    sockets: &mut SocketSet,
    context: &mut C,
    transfers: &mut ManagedSlice<'a, Option<Transfer<C::Handle>>>,
    now: Instant
) -> Result<()> where
    C: Context
[src]

Serves files from the provided context and manages any active transfers.

This function must be called after Interface::poll() to handle packed transmission and reception. File errors are handled internally by relaying an error packet to the client and terminating the transfer, if necessary.

The context and the active transfers need to be persisted across calls to this function.

Auto Trait Implementations

impl RefUnwindSafe for Server

impl Send for Server

impl Sync for Server

impl Unpin for Server

impl UnwindSafe for Server

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.