packages feed

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

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from storage (webref). Do not edit.
module JSDOM.Generated.StorageEstimate
       (newStorageEstimate, setUsage, getUsage, getUsageUnsafe, getUsageUnchecked, setQuota, getQuota, getQuotaUnsafe, getQuotaUnchecked, StorageEstimate(..), gTypeStorageEstimate)
       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://storage.spec.whatwg.org/#dictdef-storageestimate StorageEstimate specification>
newStorageEstimate :: (MonadDOM m) => m StorageEstimate
newStorageEstimate = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
setUsage :: (MonadDOM m) => StorageEstimate -> Word53 -> m ()
setUsage self val = liftDOM (void (self ^. jss "usage" (toJSVal val)))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
getUsage :: (MonadDOM m) => StorageEstimate -> m (Maybe Word53)
getUsage self = liftDOM (((self ^. js "usage") >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
getUsageUnsafe :: (MonadDOM m, HasCallStack) => StorageEstimate -> m Word53
getUsageUnsafe self = liftDOM ((((self ^. js "usage") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
getUsageUnchecked :: (MonadDOM m) => StorageEstimate -> m Word53
getUsageUnchecked self = liftDOM (((self ^. js "usage") >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
setQuota :: (MonadDOM m) => StorageEstimate -> Word53 -> m ()
setQuota self val = liftDOM (void (self ^. jss "quota" (toJSVal val)))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
getQuota :: (MonadDOM m) => StorageEstimate -> m (Maybe Word53)
getQuota self = liftDOM (((self ^. js "quota") >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
getQuotaUnsafe :: (MonadDOM m, HasCallStack) => StorageEstimate -> m Word53
getQuotaUnsafe self = liftDOM ((((self ^. js "quota") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
getQuotaUnchecked :: (MonadDOM m) => StorageEstimate -> m Word53
getQuotaUnchecked self = liftDOM (((self ^. js "quota") >>= fromJSValUnchecked))