jsaddle-dom-0.10.0.0: src/JSDOM/Generated/SerialPortFilter.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.SerialPortFilter
(newSerialPortFilter, setUsbVendorId, getUsbVendorId, getUsbVendorIdUnsafe, getUsbVendorIdUnchecked, setUsbProductId, getUsbProductId, getUsbProductIdUnsafe, getUsbProductIdUnchecked, setBluetoothServiceClassId, getBluetoothServiceClassId, getBluetoothServiceClassIdUnsafe, getBluetoothServiceClassIdUnchecked, SerialPortFilter(..), gTypeSerialPortFilter)
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-serialportfilter SerialPortFilter specification>
newSerialPortFilter :: (MonadDOM m) => m SerialPortFilter
newSerialPortFilter = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbvendorid SerialPortFilter.usbVendorId specification>
setUsbVendorId :: (MonadDOM m) => SerialPortFilter -> Word -> m ()
setUsbVendorId self val = liftDOM (void (self ^. jss "usbVendorId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbvendorid SerialPortFilter.usbVendorId specification>
getUsbVendorId :: (MonadDOM m) => SerialPortFilter -> m (Maybe Word)
getUsbVendorId self = liftDOM (((self ^. js "usbVendorId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbvendorid SerialPortFilter.usbVendorId specification>
getUsbVendorIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortFilter -> m Word
getUsbVendorIdUnsafe self = liftDOM ((((self ^. js "usbVendorId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbvendorid SerialPortFilter.usbVendorId specification>
getUsbVendorIdUnchecked :: (MonadDOM m) => SerialPortFilter -> m Word
getUsbVendorIdUnchecked self = liftDOM ((P.round <$> ((self ^. js "usbVendorId") >>= valToNumber)))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbproductid SerialPortFilter.usbProductId specification>
setUsbProductId :: (MonadDOM m) => SerialPortFilter -> Word -> m ()
setUsbProductId self val = liftDOM (void (self ^. jss "usbProductId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbproductid SerialPortFilter.usbProductId specification>
getUsbProductId :: (MonadDOM m) => SerialPortFilter -> m (Maybe Word)
getUsbProductId self = liftDOM (((self ^. js "usbProductId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbproductid SerialPortFilter.usbProductId specification>
getUsbProductIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortFilter -> m Word
getUsbProductIdUnsafe self = liftDOM ((((self ^. js "usbProductId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-usbproductid SerialPortFilter.usbProductId specification>
getUsbProductIdUnchecked :: (MonadDOM m) => SerialPortFilter -> m Word
getUsbProductIdUnchecked self = liftDOM ((P.round <$> ((self ^. js "usbProductId") >>= valToNumber)))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-bluetoothserviceclassid SerialPortFilter.bluetoothServiceClassId specification>
setBluetoothServiceClassId :: (MonadDOM m, IsBluetoothServiceUUID val) => SerialPortFilter -> val -> m ()
setBluetoothServiceClassId self val = liftDOM (void (self ^. jss "bluetoothServiceClassId" (toJSVal val)))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-bluetoothserviceclassid SerialPortFilter.bluetoothServiceClassId specification>
getBluetoothServiceClassId :: (MonadDOM m) => SerialPortFilter -> m (Maybe BluetoothServiceUUID)
getBluetoothServiceClassId self = liftDOM (((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-bluetoothserviceclassid SerialPortFilter.bluetoothServiceClassId specification>
getBluetoothServiceClassIdUnsafe :: (MonadDOM m, HasCallStack) => SerialPortFilter -> m BluetoothServiceUUID
getBluetoothServiceClassIdUnsafe self = liftDOM ((((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://serial.spec.whatwg.org/#dom-serialportfilter-bluetoothserviceclassid SerialPortFilter.bluetoothServiceClassId specification>
getBluetoothServiceClassIdUnchecked :: (MonadDOM m) => SerialPortFilter -> m BluetoothServiceUUID
getBluetoothServiceClassIdUnchecked self = liftDOM (((self ^. js "bluetoothServiceClassId") >>= fromJSValUnchecked))