File
Blob: src/workerd/io/features.h
| 1 | // Copyright (c) 2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <workerd/io/compatibility-date.capnp.h> |
| 8 | #include <workerd/jsg/jsg.h> |
| 9 | |
| 10 | namespace workerd { |
| 11 | |
| 12 | struct FeatureFlags { |
| 13 | FeatureFlags() = delete; |
| 14 | |
| 15 | // Get the feature flags that are relevant for the current jsg::Lock or |
| 16 | // throw if we are not currently executing JavaScript. |
| 17 | static CompatibilityFlags::Reader get(jsg::Lock&); |
| 18 | |
| 19 | // Alternative to get() that returns kj::none if the flags are not available. |
| 20 | // This is typically only the case in certain tests where we may only partially |
| 21 | // initialize the JS environment. |
| 22 | static kj::Maybe<CompatibilityFlags::Reader> tryGet(jsg::Lock&); |
| 23 | }; |
| 24 | |
| 25 | } // namespace workerd |