packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/WebTransportErrorOptions.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webtransport (webref). Do not edit.
module JSDOM.Generated.WebTransportErrorOptions
       (newWebTransportErrorOptions, setSource, getSource, getSourceUnsafe, getSourceUnchecked, setStreamErrorCode, getStreamErrorCode, getStreamErrorCodeUnsafe, getStreamErrorCodeUnchecked, WebTransportErrorOptions(..), gTypeWebTransportErrorOptions)
       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://w3c.github.io/webtransport/#dictdef-webtransporterroroptions WebTransportErrorOptions specification>
newWebTransportErrorOptions :: (MonadDOM m) => m WebTransportErrorOptions
newWebTransportErrorOptions = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-source WebTransportErrorOptions.source specification>
setSource :: (MonadDOM m) => WebTransportErrorOptions -> WebTransportErrorSource -> m ()
setSource self val = liftDOM (void (self ^. jss "source" (toJSVal val)))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-source WebTransportErrorOptions.source specification>
getSource :: (MonadDOM m) => WebTransportErrorOptions -> m (Maybe WebTransportErrorSource)
getSource self = liftDOM (((self ^. js "source") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-source WebTransportErrorOptions.source specification>
getSourceUnsafe :: (MonadDOM m, HasCallStack) => WebTransportErrorOptions -> m WebTransportErrorSource
getSourceUnsafe self = liftDOM ((((self ^. js "source") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-source WebTransportErrorOptions.source specification>
getSourceUnchecked :: (MonadDOM m) => WebTransportErrorOptions -> m WebTransportErrorSource
getSourceUnchecked self = liftDOM (((self ^. js "source") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-streamerrorcode WebTransportErrorOptions.streamErrorCode specification>
setStreamErrorCode :: (MonadDOM m) => WebTransportErrorOptions -> Maybe Word -> m ()
setStreamErrorCode self val = liftDOM (void (self ^. jss "streamErrorCode" (toJSVal val)))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-streamerrorcode WebTransportErrorOptions.streamErrorCode specification>
getStreamErrorCode :: (MonadDOM m) => WebTransportErrorOptions -> m (Maybe Word)
getStreamErrorCode self = liftDOM (((self ^. js "streamErrorCode") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-streamerrorcode WebTransportErrorOptions.streamErrorCode specification>
getStreamErrorCodeUnsafe :: (MonadDOM m, HasCallStack) => WebTransportErrorOptions -> m Word
getStreamErrorCodeUnsafe self = liftDOM ((((self ^. js "streamErrorCode") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/webtransport/#dom-webtransporterroroptions-streamerrorcode WebTransportErrorOptions.streamErrorCode specification>
getStreamErrorCodeUnchecked :: (MonadDOM m) => WebTransportErrorOptions -> m Word
getStreamErrorCodeUnchecked self = liftDOM ((P.round <$> ((self ^. js "streamErrorCode") >>= valToNumber)))