Skip to main content

TextField

Struct TextField 

Source
pub struct TextField<const N: usize> { /* private fields */ }
Expand description

A generic text input field for collecting user input during WiFi provisioning.

Presents a customizable text input box in the captive portal that validates and stores user-provided text in memory or flash.

Multiple TextField instances can be created with different labels and field names to collect additional configuration beyond WiFi credentials.

See the wifi_auto::fields module example for usage.

Implementations§

Source§

impl<const N: usize> TextField<N>

Source

pub const fn new_static() -> TextFieldStatic<N>

Create static resources for TextField.

See the wifi_auto::fields module example for usage.

Source

pub fn new_in_memory( text_field_static: &'static TextFieldStatic<N>, field_name: &'static str, label: &'static str, default_value: &'static str, ) -> &'static Self

Initialize a text field backed by in-memory state.

The maximum text length is determined by the generic parameter N.

Parameters:

  • text_field_static: Static resources for initialization.
  • field_name: HTML form field name (for example, device_name).
  • label: HTML label text shown in the captive portal form.
  • default_value: Initial value if nothing has been configured yet.

See the wifi_auto::fields module example for usage.

Source

pub fn new_with_flash( text_field_static: &'static TextFieldStatic<N>, text_flash_block: FlashBlockEsp, field_name: &'static str, label: &'static str, default_value: &'static str, ) -> &'static Self

Initialize a text field backed by a flash block.

The maximum text length is determined by the generic parameter N.

Parameters:

  • text_field_static: Static resources for initialization.
  • text_flash_block: Flash block for persistent storage.
  • field_name: HTML form field name (for example, device_name).
  • label: HTML label text shown in the captive portal form.
  • default_value: Initial value if nothing has been configured yet.

See the wifi_auto::fields module example for usage.

Source

pub fn text(&self) -> Result<Option<String<N>>, Error>

Return the current text, if present.

Returns None when no text has been configured yet.

See the wifi_auto::fields module example for usage.

Source

pub fn set_text(&self, text: &str) -> Result<(), Error>

Set the current text.

This allows programmatic updates to the field value.

The text must be non-empty and fit within the maximum length N.

See the wifi_auto::fields module example for usage.

Source

pub fn clear(&self) -> Result<(), Error>

Clear the current text.

Source§

impl<const N: usize> TextField<N>

Source

pub fn new( text_field_static: &'static TextFieldStatic<N>, text_flash_block: FlashBlockEsp, field_name: &'static str, label: &'static str, default_value: &'static str, ) -> &'static Self

Initialize a text field backed by a flash block.

See the WifiAutoEsp struct example for usage.

Trait Implementations§

Source§

impl<const N: usize> WifiAutoField for TextField<N>

Source§

type Error = Error

Platform crate error type used by field implementations.
Source§

fn render(&self, page: &mut HtmlBuffer) -> Result<(), Error>

Render form HTML elements.
Source§

fn parse(&self, form: &FormData<'_>) -> Result<(), Error>

Parse submitted form data and typically persist the field value.
Source§

fn is_satisfied(&self) -> Result<bool, Error>

Whether this field currently has valid configured data.
Source§

impl<const N: usize> Sync for TextField<N>

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for TextField<N>

§

impl<const N: usize> !RefUnwindSafe for TextField<N>

§

impl<const N: usize> Send for TextField<N>

§

impl<const N: usize> Unpin for TextField<N>

§

impl<const N: usize> UnsafeUnpin for TextField<N>

§

impl<const N: usize> !UnwindSafe for TextField<N>

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.