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 returnDeviceType::Unknown
rather than returning an error. - serializing
DeviceType::Unknown
will serializenull
.
This has a few important implications:
- In general,
Option<DeviceType>
should be avoided, and a plainDeviceType
used instead, because in that case,None
would be semantically identical toDeviceType::Unknown
and as mentioned above,null
already deserializes asDeviceType::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§
Trait Implementations§
source§impl Clone for DeviceType
impl Clone for DeviceType
source§fn clone(&self) -> DeviceType
fn clone(&self) -> DeviceType
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DeviceType
impl Debug for DeviceType
source§impl Default for DeviceType
impl Default for DeviceType
source§fn default() -> DeviceType
fn default() -> DeviceType
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for DeviceType
impl<'de> Deserialize<'de> for DeviceType
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for DeviceType
impl Hash for DeviceType
source§impl PartialEq for DeviceType
impl PartialEq for DeviceType
source§impl Serialize for DeviceType
impl Serialize for DeviceType
impl Copy for DeviceType
impl Eq for DeviceType
impl StructuralPartialEq for DeviceType
Auto Trait Implementations§
impl Freeze for DeviceType
impl RefUnwindSafe for DeviceType
impl Send for DeviceType
impl Sync for DeviceType
impl Unpin for DeviceType
impl UnwindSafe for DeviceType
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§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
Checks if this value is equivalent to the given key. Read more
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read more