pub struct TextField<const N: usize> { /* private fields */ }wifi and target_os=none only.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 to flash. Can be used for device names, locations, or any other text-based configuration.
Multiple TextField instances can be created with different labels and field names
to collect various pieces of information during the provisioning process.
See the wifi_auto::fields module example for usage.
Implementations§
Source§impl<const N: usize> TextField<N>
impl<const N: usize> TextField<N>
Sourcepub const fn new_static() -> TextFieldStatic<N>
pub const fn new_static() -> TextFieldStatic<N>
Create static resources for TextField.
See the wifi_auto::fields module example for usage.
Sourcepub fn new(
text_field_static: &'static TextFieldStatic<N>,
flash: FlashBlock,
field_name: &'static str,
label: &'static str,
default_value: &'static str,
) -> &'static Self
pub fn new( text_field_static: &'static TextFieldStatic<N>, flash: FlashBlock, field_name: &'static str, label: &'static str, default_value: &'static str, ) -> &'static Self
Initialize a new text input field.
§Parameters
text_field_static: Static resources for initializationflash: Flash block for persistent storagefield_name: HTML form field name (e.g., “device_name”, “location”)label: HTML label text (e.g., “Device Name:”, “Location:”)default_value: Initial value if nothing saved
The maximum length is determined by the generic parameter N.
See the wifi_auto::fields module example for usage.
Sourcepub fn text(&self) -> Result<Option<String<N>>>
pub fn text(&self) -> Result<Option<String<N>>>
Load the stored text from flash.
Returns None if no text has been configured yet.
See the wifi_auto::fields module example for usage.
Sourcepub fn set_text(&self, text: &String<N>) -> Result<()>
pub fn set_text(&self, text: &String<N>) -> Result<()>
Save new text to flash.
This method allows programmatic updates to the field value, such as when the user modifies configuration via button presses or other UI interactions.
The text must not exceed the maximum length N specified in the type parameter.
Alternatively, you can access the underlying flash block directly for more control over flash operations.
Trait Implementations§
Source§impl<const N: usize> WifiAutoField for TextField<N>
impl<const N: usize> WifiAutoField for TextField<N>
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> !UnwindSafe for TextField<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more