esp_idf_svc::io::vfs

Struct BlockingStdIo

Source
pub struct BlockingStdIo<'d, T> { /* private fields */ }
Expand description

A utility for setting up a buffered and blocking communication for the Rust stdio subsystem.

By default, all communication via std::io:stdin / std::io::stdout on the ESP-IDF is non-blocking. One consequence of this, is that if the user wants to read from std::io::stdin, she has to constantly poll the driver, since the respective hardware FIFO buffers are relatively small-ish. Also the user would have to handle WouldBlock errors on every call, which is not very ergonomic.

Instantiating the BlockingStdIo instructs the ESP-IDF VFS (Virtual File System) to use the interrupt-driven drivers instead, as well as their blocking read / write functions.

Implementations§

Source§

impl<'d, T> BlockingStdIo<'d, T>
where T: BorrowMut<UartDriver<'d>>,

Source

pub fn uart(driver: T) -> Result<Self, EspError>

Create a BlockingStdIo instance for a UART driver

Arguments:

  • driver: The UART driver to use (i.e. a UartDriver instance that can be mutably borrowed)
Source§

impl<'d, T> BlockingStdIo<'d, T>
where T: BorrowMut<UsbSerialDriver<'d>>,

Source

pub fn usb_serial(driver: T) -> Result<Self, EspError>

Create a BlockingStdIo instance for a USB-SERIAL driver

NOTE: By default, println! and log! output will be redirected to it in case no UART connection is established to a Host PC. The peripheral is initialized at startup and is using the ESP console slot 2 by default.

NOTE: ESP console slot 2 cannot be used to read from the HOST, only writing is supported. If reading from the HOST is necessary, reconfigure the ESP console by setting the following into your projects sdkconfig.default file:

CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y

Arguments:

  • driver: The USB-SERIAL driver to use (i.e. a UsbSerialDriver instance that can be mutably borrowed)

Trait Implementations§

Source§

impl<T> Drop for BlockingStdIo<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d, T> Freeze for BlockingStdIo<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for BlockingStdIo<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for BlockingStdIo<'d, T>
where T: Send,

§

impl<'d, T> Sync for BlockingStdIo<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for BlockingStdIo<'d, T>
where T: Unpin,

§

impl<'d, T> !UnwindSafe for BlockingStdIo<'d, T>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.