Skip to main content

Autocomplete

Enum Autocomplete 

Source
#[non_exhaustive]
pub enum Autocomplete {
Show 39 variants Off, Name, Email, Username, CurrentPassword, NewPassword, OneTimeCode, GivenName, AdditionalName, FamilyName, HonorificPrefix, Nickname, Organization, OrganizationTitle, StreetAddress, AddressLine1, AddressLine2, AddressLine3, AddressLevel1, AddressLevel2, AddressLevel3, PostalCode, Country, CountryCode, CcName, CcNumber, CcExp, CcExpMonth, CcExpYear, CcCsc, Bday, BdayDay, BdayMonth, BdayYear, Sex, Language, Tel, TelNational, Url,
}
Expand description

What a TextField holds, as autocomplete names it for the browser and for WCAG 1.3.5.

The variants are the WHATWG autofill field names a sign-up form and a checkout ask for. A form that asks for a shipping and a billing address on one page has no way here to mark which is which.

use hypersig::Signals;
use hypersig_ui::{Autocomplete, TextField};
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Address {
    city: String,
}

let city = TextField::new("City", Address::city()).autocomplete(Autocomplete::AddressLevel2);
assert!(city.render().render().contains(r#"autocomplete="address-level2""#));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Off

off: the browser offers nothing.

§

Name

name.

§

Email

email.

§

Username

username.

§

CurrentPassword

current-password.

§

NewPassword

new-password.

§

OneTimeCode

one-time-code.

§

GivenName

given-name: the first name in Western order.

§

AdditionalName

additional-name: a middle name.

§

FamilyName

family-name: the last name in Western order.

§

HonorificPrefix

honorific-prefix, such as “Dr.”.

§

Nickname

nickname.

§

Organization

organization.

§

OrganizationTitle

organization-title: a job title.

§

StreetAddress

street-address, for a field that takes the whole street address.

§

AddressLine1

address-line1.

§

AddressLine2

address-line2.

§

AddressLine3

address-line3.

§

AddressLevel1

address-level1: a state, a province, or a prefecture.

§

AddressLevel2

address-level2: a city or a town.

§

AddressLevel3

address-level3: a district within a city.

§

PostalCode

postal-code.

§

Country

country-name.

§

CountryCode

country: an ISO 3166-1 alpha-2 country code.

§

CcName

cc-name: the name on a payment card.

§

CcNumber

cc-number.

§

CcExp

cc-exp: the expiry date of a payment card.

§

CcExpMonth

cc-exp-month.

§

CcExpYear

cc-exp-year.

§

CcCsc

cc-csc: the security code of a payment card.

§

Bday

bday: a birthday.

§

BdayDay

bday-day.

§

BdayMonth

bday-month.

§

BdayYear

bday-year.

§

Sex

sex: a gender identity, as free text.

§

Language

language: a preferred language, as a BCP 47 tag.

§

Tel

tel.

§

TelNational

tel-national: a phone number without the country code.

§

Url

url.

Trait Implementations§

Source§

impl Clone for Autocomplete

Source§

fn clone(&self) -> Autocomplete

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Autocomplete

Source§

impl Debug for Autocomplete

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Autocomplete

Source§

impl Hash for Autocomplete

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Autocomplete

Source§

fn eq(&self, other: &Autocomplete) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Autocomplete

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.