pub struct TextInput<B> { /* private fields */ }ui only.Expand description
▦ 𝐓 One-line editable text state over caller-chosen storage.
📦 size_of::<TextInput<&mut [u8]>>() == 28 bytes / 224 bits #️⃣ #[cfg(target_pointer_width = “32”)]
⚗️Option<T> 🟰 T
📦 size_of::<TextInput<&mut [u8]>>() == 56 bytes / 448 bits #️⃣ #[cfg(target_pointer_width = “64”)]
⚗️Option<T> 🟰 T
The storage type determines ownership:
TextInput<[u8; N]>owns inline storage.TextInput<&mut [u8]>edits caller-provided storage.TextInput<String>uses growable allocated storage.
Implementations§
Source§impl<B> TextInput<B>
impl<B> TextInput<B>
Sourcepub const fn from_storage(storage: B) -> Self
pub const fn from_storage(storage: B) -> Self
Creates an empty text input over storage.
Sourcepub const fn from_storage_config(storage: B, config: TextInputConfig) -> Self
pub const fn from_storage_config(storage: B, config: TextInputConfig) -> Self
Creates an empty text input over storage, with config.
Sourcepub const fn is_cursor_start(&self) -> bool
pub const fn is_cursor_start(&self) -> bool
Returns whether the cursor is at the beginning.
Sourcepub const fn is_cursor_end(&self) -> bool
pub const fn is_cursor_end(&self) -> bool
Returns whether the cursor is at the end.
Sourcepub const fn config(&self) -> TextInputConfig
pub const fn config(&self) -> TextInputConfig
Returns the input configuration.
Sourcepub const fn set_config(&mut self, config: TextInputConfig)
pub const fn set_config(&mut self, config: TextInputConfig)
Sets the input configuration.
Sourcepub const fn storage_mut(&mut self) -> &mut B
pub const fn storage_mut(&mut self) -> &mut B
Returns mutable access to the underlying storage.
Sourcepub fn into_storage(self) -> B
pub fn into_storage(self) -> B
Consumes the input and returns its storage.
Source§impl<const CAP: usize> TextInput<[u8; CAP]>
impl<const CAP: usize> TextInput<[u8; CAP]>
Sourcepub const fn remaining_capacity(&self) -> usize
pub const fn remaining_capacity(&self) -> usize
Returns the remaining storage capacity, in bytes.
Sourcepub fn try_set_cursor(&mut self, cursor: usize) -> bool
pub fn try_set_cursor(&mut self, cursor: usize) -> bool
Tries to set the cursor to a UTF-8 boundary.
Sourcepub fn view(&self) -> TextInputView<'_>
pub fn view(&self) -> TextInputView<'_>
Returns a borrowed input view.
Sourcepub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
pub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
Applies an editing action.
Source§impl<'a> TextInput<&'a mut [u8]>
impl<'a> TextInput<&'a mut [u8]>
Sourcepub const fn from_buf(buf: &'a mut [u8]) -> Self
pub const fn from_buf(buf: &'a mut [u8]) -> Self
Creates an empty input over caller-provided storage.
Sourcepub const fn from_buf_config(buf: &'a mut [u8], config: TextInputConfig) -> Self
pub const fn from_buf_config(buf: &'a mut [u8], config: TextInputConfig) -> Self
Creates an empty input over caller-provided storage, with config.
Sourcepub const fn remaining_capacity(&self) -> usize
pub const fn remaining_capacity(&self) -> usize
Returns the remaining storage capacity, in bytes.
Sourcepub fn try_set_cursor(&mut self, cursor: usize) -> bool
pub fn try_set_cursor(&mut self, cursor: usize) -> bool
Tries to set the cursor to a UTF-8 boundary.
Sourcepub fn view(&self) -> TextInputView<'_>
pub fn view(&self) -> TextInputView<'_>
Returns a borrowed input view.
Sourcepub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
pub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
Applies an editing action.
Source§impl TextInput<String>
impl TextInput<String>
Sourcepub fn new_alloc() -> Self
Available on crate feature alloc only.
pub fn new_alloc() -> Self
alloc only.Creates an empty allocated input.
Sourcepub fn from_string(storage: String) -> Self
Available on crate feature alloc only.
pub fn from_string(storage: String) -> Self
alloc only.Creates an input from an allocated string.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
Available on crate feature alloc only.
pub fn as_bytes(&self) -> &[u8] ⓘ
alloc only.Returns the initialized bytes.
Sourcepub fn as_str(&self) -> &str ⓘ
Available on crate feature alloc only.
pub fn as_str(&self) -> &str ⓘ
alloc only.Returns the initialized UTF-8 text.
Sourcepub fn try_set_cursor(&mut self, cursor: usize) -> bool
Available on crate feature alloc only.
pub fn try_set_cursor(&mut self, cursor: usize) -> bool
alloc only.Tries to set the cursor to a UTF-8 boundary.
Sourcepub fn view(&self) -> TextInputView<'_>
Available on crate feature alloc only.
pub fn view(&self) -> TextInputView<'_>
alloc only.Returns a borrowed input view.
Sourcepub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
Available on crate feature alloc only.
pub fn apply(&mut self, action: TextInputAction) -> TextInputOutcome
alloc only.Applies an editing action.
Trait Implementations§
impl<B: Eq> Eq for TextInput<B>
impl<B: PartialEq> StructuralPartialEq for TextInput<B>
Auto Trait Implementations§
impl<B> Freeze for TextInput<B>where
B: Freeze,
impl<B> RefUnwindSafe for TextInput<B>where
B: RefUnwindSafe,
impl<B> Send for TextInput<B>where
B: Send,
impl<B> Sync for TextInput<B>where
B: Sync,
impl<B> Unpin for TextInput<B>where
B: Unpin,
impl<B> UnsafeUnpin for TextInput<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for TextInput<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.