mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
- Disable default features in dependencies - Use anyhow::Error::msg to map errors. Note: anyhow will itself be removed later. - lazy_static/spin_no_std used in no_std environments - ensure_no_std binary is built to target thumbv7m-none-eabi to ensure that there are no std dependencies. thumbv7m-none-eabi target has no std support. - The opa-no-std feature enables only those Regorus features that work with no_std. - Enable tests with no_std - Update sizes of regorus binary in README.md - Ensure that regorus example can be built with only std - Ensure that regorus example can be built with no_std Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
123 lines
2.6 KiB
Rust
123 lines
2.6 KiB
Rust
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
mod aggregates;
|
|
mod arrays;
|
|
mod bitwise;
|
|
pub mod comparison;
|
|
mod conversions;
|
|
|
|
#[cfg(feature = "crypto")]
|
|
mod crypto;
|
|
#[cfg(feature = "deprecated")]
|
|
pub mod deprecated;
|
|
mod encoding;
|
|
#[cfg(feature = "glob")]
|
|
mod glob;
|
|
#[cfg(feature = "graph")]
|
|
mod graph;
|
|
#[cfg(feature = "http")]
|
|
mod http;
|
|
#[cfg(feature = "jwt")]
|
|
mod jwt;
|
|
pub mod numbers;
|
|
mod objects;
|
|
#[cfg(feature = "opa-runtime")]
|
|
mod opa;
|
|
#[cfg(feature = "regex")]
|
|
mod regex;
|
|
#[cfg(feature = "semver")]
|
|
mod semver;
|
|
pub mod sets;
|
|
mod strings;
|
|
#[cfg(feature = "time")]
|
|
mod time;
|
|
mod tracing;
|
|
pub mod types;
|
|
mod units;
|
|
mod utils;
|
|
#[cfg(feature = "uuid")]
|
|
mod uuid;
|
|
|
|
#[cfg(feature = "opa-testutil")]
|
|
mod test;
|
|
|
|
use crate::ast::{Expr, Ref};
|
|
use crate::lexer::Span;
|
|
use crate::value::Value;
|
|
|
|
use crate::Map as BuiltinsMap;
|
|
|
|
use anyhow::Result;
|
|
use lazy_static::lazy_static;
|
|
|
|
pub type BuiltinFcn = (fn(&Span, &[Ref<Expr>], &[Value], bool) -> Result<Value>, u8);
|
|
|
|
#[cfg(feature = "deprecated")]
|
|
pub use deprecated::DEPRECATED;
|
|
|
|
#[rustfmt::skip]
|
|
lazy_static! {
|
|
pub static ref BUILTINS: BuiltinsMap<&'static str, BuiltinFcn> = {
|
|
let mut m : BuiltinsMap<&'static str, BuiltinFcn> = BuiltinsMap::new();
|
|
|
|
// comparison functions are directly called.
|
|
numbers::register(&mut m);
|
|
aggregates::register(&mut m);
|
|
arrays::register(&mut m);
|
|
sets::register(&mut m);
|
|
objects::register(&mut m);
|
|
strings::register(&mut m);
|
|
|
|
#[cfg(feature = "regex")]
|
|
regex::register(&mut m);
|
|
|
|
#[cfg(feature = "glob")]
|
|
glob::register(&mut m);
|
|
|
|
#[cfg(feature = "graph")]
|
|
graph::register(&mut m);
|
|
|
|
bitwise::register(&mut m);
|
|
conversions::register(&mut m);
|
|
//units::register(&mut m);
|
|
types::register(&mut m);
|
|
encoding::register(&mut m);
|
|
#[cfg(feature = "jwt")]
|
|
jwt::register(&mut m);
|
|
#[cfg(feature = "time")]
|
|
time::register(&mut m);
|
|
|
|
#[cfg(feature = "crypto")]
|
|
crypto::register(&mut m);
|
|
//graphql::register(&mut m);
|
|
#[cfg(feature = "http")]
|
|
http::register(&mut m);
|
|
//net::register(&mut m);
|
|
#[cfg(feature = "uuid")]
|
|
uuid::register(&mut m);
|
|
#[cfg(feature = "semver")]
|
|
semver::register(&mut m);
|
|
//rego::register(&mut m);
|
|
#[cfg(feature = "opa-runtime")]
|
|
opa::register(&mut m);
|
|
tracing::register(&mut m);
|
|
units::register(&mut m);
|
|
|
|
#[cfg(feature = "opa-testutil")]
|
|
test::register(&mut m);
|
|
|
|
m
|
|
};
|
|
}
|
|
|
|
pub fn must_cache(path: &str) -> Option<&'static str> {
|
|
match path {
|
|
"opa.runtime" => Some("opa.runtime"),
|
|
"rand.intn" => Some("rand.intn"),
|
|
"time.now_ns" => Some("time.now_ns"),
|
|
"uuid.rfc4122" => Some("uuid.rfc4122"),
|
|
_ => None,
|
|
}
|
|
}
|