jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SerialPortInfo.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from serial (webref). Do not edit.
module JSDOM.Generated.SerialPortInfo
(newSerialPortInfo, setUsbVendorId, getUsbVendorId, getUsbVendorIdUnsafe, getUsbVendorIdUnchecked, setUsbProductId, getUsbProductId, getUsbProductIdUnsafe, getUsbProductIdUnchecked, setBluetoothServiceClassId, getBluetoothServiceClassId, getBluetoothServiceClassIdUnsafe, getBluetoothServiceClassIdUnchecked, SerialPortInfo(..), gTypeSerialPortInfo)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://serial.spec.whatwg.org/#dictdef-serialportinfo SerialPortInfo specification>
newSerialPortInfo :: (MonadDOM m) => m SerialPortInfo
newSerialPortInfo = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbvendorid SerialPortInfo.usbVendorId specification>
setUsbVendorId :: (MonadDOM m) => SerialPortInfo -> Word -> m ()
setUsbVendorId self val = liftDOM (void (self ^. jss "usbVendorId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbvendorid SerialPortInfo.usbVendorId specification>
getUsbVendorId :: (MonadDOM m) => SerialPortInfo -> m (Maybe Word)
getUsbVendorId self = liftDOM (((self ^. js "usbVendorId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbvendorid SerialPortInfo.usbVendorId specification>
getUsbVendorIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortInfo -> m Word
getUsbVendorIdUnsafe self = liftDOM ((((self ^. js "usbVendorId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbvendorid SerialPortInfo.usbVendorId specification>
getUsbVendorIdUnchecked :: (MonadDOM m) => SerialPortInfo -> m Word
getUsbVendorIdUnchecked self = liftDOM ((P.round <$> ((self ^. js "usbVendorId") >>= valToNumber)))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbproductid SerialPortInfo.usbProductId specification>
setUsbProductId :: (MonadDOM m) => SerialPortInfo -> Word -> m ()
setUsbProductId self val = liftDOM (void (self ^. jss "usbProductId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbproductid SerialPortInfo.usbProductId specification>
getUsbProductId :: (MonadDOM m) => SerialPortInfo -> m (Maybe Word)
getUsbProductId self = liftDOM (((self ^. js "usbProductId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbproductid SerialPortInfo.usbProductId specification>
getUsbProductIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortInfo -> m Word
getUsbProductIdUnsafe self = liftDOM ((((self ^. js "usbProductId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-usbproductid SerialPortInfo.usbProductId specification>
getUsbProductIdUnchecked :: (MonadDOM m) => SerialPortInfo -> m Word
getUsbProductIdUnchecked self = liftDOM ((P.round <$> ((self ^. js "usbProductId") >>= valToNumber)))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-bluetoothserviceclassid SerialPortInfo.bluetoothServiceClassId specification>
setBluetoothServiceClassId :: (MonadDOM m, IsBluetoothServiceUUID val) => SerialPortInfo -> val -> m ()
setBluetoothServiceClassId self val = liftDOM (void (self ^. jss "bluetoothServiceClassId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-bluetoothserviceclassid SerialPortInfo.bluetoothServiceClassId specification>
getBluetoothServiceClassId :: (MonadDOM m) => SerialPortInfo -> m (Maybe BluetoothServiceUUID)
getBluetoothServiceClassId self = liftDOM (((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-bluetoothserviceclassid SerialPortInfo.bluetoothServiceClassId specification>
getBluetoothServiceClassIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortInfo -> m BluetoothServiceUUID
getBluetoothServiceClassIdUnsafe self = liftDOM ((((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportinfo-bluetoothserviceclassid SerialPortInfo.bluetoothServiceClassId specification>
getBluetoothServiceClassIdUnchecked :: (MonadDOM m) => SerialPortInfo -> m BluetoothServiceUUID
getBluetoothServiceClassIdUnchecked self = liftDOM (((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked))