Struct TftpServerBuilder

Source
pub struct TftpServerBuilder<H: Handler> { /* private fields */ }
Expand description

TFTP server builder.

Implementations§

Source§

impl TftpServerBuilder<DirHandler>

Source

pub fn with_dir_ro<P>(dir: P) -> Result<TftpServerBuilder<DirHandler>>
where P: AsRef<Path>,

Create new buidler with DirHandler that serves only read requests.

Source

pub fn with_dir_wo<P>(dir: P) -> Result<TftpServerBuilder<DirHandler>>
where P: AsRef<Path>,

Create new buidler with DirHandler that serves only write requests.

Source

pub fn with_dir_rw<P>(dir: P) -> Result<TftpServerBuilder<DirHandler>>
where P: AsRef<Path>,

Create new buidler with DirHandler that serves read and write requests.

Source§

impl<H: Handler> TftpServerBuilder<H>

Source

pub fn with_handler(handler: H) -> Self

Create new builder with custom Handler.

Source

pub fn bind(self, addr: SocketAddr) -> Self

Set listening address.

This is ignored if underling socket is set.

Default: 0.0.0.0:69

Source

pub fn socket(self, socket: Async<UdpSocket>) -> Self

Set underling UDP socket.

Source

pub fn std_socket(self, socket: UdpSocket) -> Result<Self>

Set underling UDP socket.

Source

pub fn timeout(self, timeout: Duration) -> Self

Set retry timeout.

Client can override this (RFC2349). If you want to enforce it you must combine it ignore_client_timeout.

This crate allows you to set non-standard timeouts (i.e. timeouts that are less than a second). However if you choose to do it make sure you test it well in your environment since client’s behavior is undefined.

Default: 3 seconds

Source

pub fn block_size_limit(self, size: u16) -> Self

Set maximum block size.

Client can request a specific block size (RFC2348). Use this option if you want to set a limit.

Real life scenario: U-Boot does not support IP fragmentation and requests block size of 1468. This works fine if your MTU is 1500 bytes, however if you are accessing client through a VPN, then transfer will never start. Use this option to workaround the problem.

Source

pub fn max_send_retries(self, retries: u32) -> Self

Set maximum send retries for a data block.

On timeout server will try to send the data block again. When retries are reached for the specific data block the server closes the connection with the client.

Default: 100 retries.

Source

pub fn ignore_client_timeout(self) -> Self

Ignore client’s timeout option.

With this you enforce server’s timeout by ignoring client’s timeout option of RFC2349.

Source

pub fn ignore_client_block_size(self) -> Self

Ignore client’s block size option.

With this you can ignore client’s blksize option of RFC2348. This will enforce 512 block size that is defined in RFC1350.

Source

pub async fn build(self) -> Result<TftpServer<H>>

Build TftpServer.

Auto Trait Implementations§

§

impl<H> Freeze for TftpServerBuilder<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for TftpServerBuilder<H>
where H: RefUnwindSafe,

§

impl<H> Send for TftpServerBuilder<H>

§

impl<H> Sync for TftpServerBuilder<H>
where H: Sync,

§

impl<H> Unpin for TftpServerBuilder<H>
where H: Unpin,

§

impl<H> UnwindSafe for TftpServerBuilder<H>
where H: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.