pub enum DeviceType {
    Desktop,
    Mobile,
    Tablet,
    VR,
    TV,
    Unknown,
}
Expand description

Enumeration for the different types of device.

Firefox Accounts and the broader Sync universe separates devices into broad categories for various purposes, such as distinguishing a desktop PC from a mobile phone.

A special variant in this enum, DeviceType::Unknown is used to capture the string values we don’t recognise. It also has a custom serde serializer and deserializer which implements the following semantics:

  • deserializing a DeviceType which uses a string value we don’t recognise or null will return DeviceType::Unknown rather than returning an error.
  • serializing DeviceType::Unknown will serialize null.

This has a few important implications:

  • In general, Option<DeviceType> should be avoided, and a plain DeviceType used instead, because in that case, None would be semantically identical to DeviceType::Unknown and as mentioned above, null already deserializes as DeviceType::Unknown.
  • Any unknown device types can not be round-tripped via this enum - eg, if you deserialize a struct holding a DeviceType string value we don’t recognize, then re-serialize it, the original string value is lost. We don’t consider this a problem because in practice, we only upload records with this device’s type, not the type of other devices, and it’s reasonable to assume that this module knows about all valid device types for the device type it is deployed on.

Variants§

§

Desktop

§

Mobile

§

Tablet

§

VR

§

TV

§

Unknown

Trait Implementations§

§

impl Clone for DeviceType

§

fn clone(&self) -> DeviceType

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for DeviceType

§

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

Formats the value using the given formatter. Read more
§

impl Default for DeviceType

§

fn default() -> DeviceType

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for DeviceType

§

fn deserialize<D>( deserializer: D ) -> Result<DeviceType, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Hash for DeviceType

§

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

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
§

impl PartialEq for DeviceType

§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for DeviceType

§

fn serialize<S>( &self, s: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl Copy for DeviceType

§

impl Eq for DeviceType

§

impl StructuralEq for DeviceType

§

impl StructuralPartialEq for DeviceType

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for Twhere T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<>
§

fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,