Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Common Expression Language interpreter written in Rust

License

NotificationsYou must be signed in to change notification settings

cel-rust/cel-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust

TheCommon Expression Language (CEL) is a non-Turing complete language designedfor simplicity, speed, safety, andportability. CEL's C-like syntax looks nearly identical to equivalent expressions in C++, Go, Java, and TypeScript. CELis ideal for lightweight expression evaluation when a fully sandboxed scripting language is too resource intensive.

// Check whether a resource name starts with a group name.resource.name.startsWith("/groups/" +auth.claims.group)
// Determine whether the request is in the permitted time window.request.time-resource.age<duration("24h")
// Check whether all resource names in a list match a given filter.auth.claims.email_verified&&resources.all(r,r.startsWith(auth.claims.email))

Getting Started

This project includes a CEL-parser and an interpreter which means that it can be used to evaluate CEL-expressions. Thelibrary aims to be very simple to use, while still being fast, safe, and customizable.

fnmain(){let program =Program::compile("add(2, 3) == 5").unwrap();letmut context =Context::default();    context.add_function("add", |a:i64,b:i64| a + b);let value = program.execute(&context).unwrap();assert_eq!(value,true.into());}

Examples

Check out these other examples to learn how to use this library:

  • Simple - A simple example of how to use the library.
  • Variables - Passing variables and using them in your program.
  • Functions - Defining and using custom functions in your program.
  • Concurrent Execution - Executing the same program concurrently.

About

Common Expression Language interpreter written in Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp