packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/StorageEstimate.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from storage (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.StorageEstimate
       (js_newStorageEstimate, js_setUsage, js_getUsage, js_setQuota, js_getQuota, 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 GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(() => { return ({}); })"
        js_newStorageEstimate :: IO StorageEstimate
-- | <https://storage.spec.whatwg.org/#dictdef-storageestimate StorageEstimate specification>
newStorageEstimate :: (MonadDOM m) => m StorageEstimate
newStorageEstimate = liftDOM ((js_newStorageEstimate))

foreign import javascript safe "(($1, $2) => { $1[\"usage\"] = $2; })"
        js_setUsage :: StorageEstimate -> JSVal -> IO ()
-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
setUsage :: (MonadDOM m) => StorageEstimate -> Word53 -> m ()
setUsage self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setUsage (self) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"usage\"]; })"
        js_getUsage :: StorageEstimate -> IO JSVal
-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
getUsage :: (MonadDOM m) => StorageEstimate -> m (Maybe Word53)
getUsage self = liftDOM (((js_getUsage (self)) >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-usage StorageEstimate.usage specification>
getUsageUnsafe :: (MonadDOM m, HasCallStack) => StorageEstimate -> m Word53
getUsageUnsafe self = liftDOM ((((js_getUsage (self)) >>= 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 ((pFromJSVal <$> (js_getUsage (self))))

foreign import javascript safe "(($1, $2) => { $1[\"quota\"] = $2; })"
        js_setQuota :: StorageEstimate -> JSVal -> IO ()
-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
setQuota :: (MonadDOM m) => StorageEstimate -> Word53 -> m ()
setQuota self val = liftDOM (void (((toJSVal val) >>= \a2' -> js_setQuota (self) a2')))

foreign import javascript unsafe "(($1) => { return $1[\"quota\"]; })"
        js_getQuota :: StorageEstimate -> IO JSVal
-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
getQuota :: (MonadDOM m) => StorageEstimate -> m (Maybe Word53)
getQuota self = liftDOM (((js_getQuota (self)) >>= fromJSValUnchecked))

-- | <https://storage.spec.whatwg.org/#dom-storageestimate-quota StorageEstimate.quota specification>
getQuotaUnsafe :: (MonadDOM m, HasCallStack) => StorageEstimate -> m Word53
getQuotaUnsafe self = liftDOM ((((js_getQuota (self)) >>= 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 ((pFromJSVal <$> (js_getQuota (self))))