boundless_market/util.rs
1// Copyright 2026 Boundless Foundation, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/// Type used in the [Client] and [StandardRequestBuilder] to indicate that the component in question is not provided.
16///
17/// Note that this in an [uninhabited type] and cannot be instantiated. When used as
18/// `Option<NotProvided>`, the only possible variant for this option is `None`.
19///
20/// [uninhabited type]: https://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/
21/// [StandardRequestBuilder]: crate::request_builder::StandardRequestBuilder
22/// [Client]: crate::client::Client
23#[derive(Copy, Clone, Debug)]
24pub enum NotProvided {}
25
26/// A very small utility function to get the current unix timestamp.
27// TODO(#379): Avoid drift relative to the chain's timestamps.
28#[cfg(not(target_os = "zkvm"))]
29pub(crate) fn now_timestamp() -> u64 {
30 std::time::SystemTime::now()
31 .duration_since(std::time::SystemTime::UNIX_EPOCH)
32 .unwrap()
33 .as_secs()
34}
35
36/// Returns `true` if the dev mode environment variable is enabled.
37#[cfg(not(target_os = "zkvm"))]
38pub(crate) fn is_dev_mode() -> bool {
39 std::env::var("RISC0_DEV_MODE")
40 .ok()
41 .map(|x| x.to_lowercase())
42 .filter(|x| x == "1" || x == "true" || x == "yes")
43 .is_some()
44}