use crate::{_tags, js_int32};
#[doc = _tags!(web)]
#[doc = crate::_doc_location!("sys/os/browser/web")]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum WebPermission {
#[doc = _tags!(experimental)]
Accelerometer,
#[doc = _tags!(experimental)]
BackgroundSync,
Camera,
#[doc = _tags!(experimental non_standard)]
ClipboardRead,
#[doc = _tags!(experimental)]
#[doc = _tags!(experimental)]
ClipboardWrite,
Geolocation,
#[doc = _tags!(experimental)]
Gyroscope,
Microphone,
Midi,
Notifications,
#[doc = _tags!(experimental)]
PaymentHandler,
PersistentStorage,
Push,
ScreenWakeLock,
StorageAccess,
#[doc = _tags!(experimental)]
TopLevelStorageAccess,
}
impl WebPermission {
pub fn as_str(self) -> &'static str {
use WebPermission as P;
match self {
P::Accelerometer => "accelerometer",
P::BackgroundSync => "background-sync",
P::Camera => "camera",
P::ClipboardRead => "clipboard-read",
P::ClipboardWrite => "clipboard-write",
P::Geolocation => "geolocation",
P::Gyroscope => "gyroscope",
P::Microphone => "microphone",
P::Midi => "midi",
P::Notifications => "notifications",
P::PaymentHandler => "payment-handler",
P::PersistentStorage => "persistent-storage",
P::Push => "push",
P::ScreenWakeLock => "screen-wake-lock",
P::StorageAccess => "storage-access",
P::TopLevelStorageAccess => "top-level-storage-access",
}
}
}
#[doc = _tags!(web result)]
#[doc = crate::_doc_location!("sys/os/browser/web")]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[repr(i8)]
pub enum WebPermissionState {
Granted = 1,
Prompt = 0,
Denied = -1,
Unknown = -2,
Error = -3,
}
impl From<js_int32> for WebPermissionState {
fn from(from: js_int32) -> Self {
use WebPermissionState as S;
match from {
1 => S::Granted,
0 => S::Prompt,
-1 => S::Denied,
-2 => S::Unknown,
_ => S::Error,
}
}
}