#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum Intrinsic { TestAssert, TestAssertEq, TestSecret, JobServe, TestJobDrain, TestClockAdvance, CryptoToken, CryptoPasswordHash, CryptoPasswordVerify, CryptoSha256, CryptoHmacSha256, CryptoConstantTimeEq, TextTrim, TextLower, TextUpper, TextCodepoint, TextFromCodepoint, TextAt, TextSlice, TextIndexOf, TextContains, TextStartsWith, TextEndsWith, TextSplit, TextReplace, IntParse, IntToText, DecimalParse, DecimalToText, DecimalFromInt, FloatParse, FloatToText, ProcessArguments, TimeUnixMillis, TimeNow, TimeParseDateTime, TimeFormatDateTime, TimeParseDate, TimeFormatDate, TimeParseTime, TimeFormatTime, TimeDuration, TimeAdd, TimeSubtract, TimeDifference, TimeMonotonicNanos, TimeSleep, TaskSleep, TaskTicks, TaskTimeout, TaskRace, StreamOf, TlsSystem, TlsClient, TlsServer, HttpClientNew, HttpRequest, HttpOpen, HttpOpenStream, HttpCloseClient, HttpServeTls, HttpServeLiveTls, WsOpen, DecimalRound, FloatFromInt, FloatSqrt, FloatSin, FloatCos, FloatLog, FloatPow, FloatIsNan, FloatIsFinite, FloatIsInfinite, StdoutWrite, LogDebug, LogInfo, LogWarn, LogError, IdFromText, IdToText, UuidParse, UuidToText, BytesFromText, BytesToText, BytesFromInts, BytesLength, BytesAt, BytesSlice, BytesConcat, FileOpen, FileCreate, FileRead, FileWrite, FileClose, FileChunks, TcpConnect, TcpConnectTimeout, TcpListen, TcpAccept, TcpPort, TcpRead, TcpWrite, TcpTimeout, TcpClose, TcpCloseListener, TcpChunks, TcpConnections, HttpServe, ApiServe, UploadFilename, UploadContentType, UploadSize, UploadClose, UploadStore, ApiRequestId, ApiMethod, ApiPath, ApiClientAddress, ApiHeader, ApiCookie, ApiSecretCookie, ApiResponseHeader, ApiResponseCookie, ApiResponseSecretCookie, AuthIssue, AuthIssueCookie, AuthClearCookie, AuthOwnsUser, AuthId, AuthSession, AuthUserId, AuthTenantId, AuthPermissions, AuthSaveRole, AuthGrantRole, AuthRevokeRole, AuthDisableRole, SiteKey, HttpSend, HttpServeLive, HttpRespond, HttpStart, HttpWrite, HttpFinish, SseStart, SseSend, WsAccept, WsConnect, WsSend, WsReceive, WsMessages, WsClose, } impl Intrinsic { pub fn is_async(self) -> bool { matches!( self, Self::UploadStore | Self::HttpClientNew | Self::HttpRequest | Self::HttpOpen | Self::HttpOpenStream | Self::HttpCloseClient | Self::HttpServeTls | Self::HttpServeLiveTls | Self::WsOpen | Self::TaskTicks | Self::TaskSleep | Self::TaskTimeout | Self::TaskRace | Self::TcpConnect | Self::TcpConnectTimeout | Self::TcpListen | Self::TcpAccept | Self::TcpRead | Self::TcpWrite | Self::HttpServe | Self::ApiServe | Self::JobServe | Self::TestJobDrain | Self::HttpSend | Self::HttpServeLive | Self::HttpRespond | Self::HttpStart | Self::HttpWrite | Self::HttpFinish | Self::SseStart | Self::SseSend | Self::AuthPermissions | Self::AuthSaveRole | Self::AuthGrantRole | Self::AuthRevokeRole | Self::AuthDisableRole | Self::WsAccept | Self::WsConnect | Self::WsSend | Self::WsReceive | Self::WsClose ) } pub fn from_name(name: &str) -> Option { match name { "dever.test.drain_jobs" => return Some(Self::TestJobDrain), "dever.test.advance_clock" => return Some(Self::TestClockAdvance), "dever.auth.owns_user" => return Some(Self::AuthOwnsUser), _ => {} } Some(match name.strip_prefix("dever.system.")? { "job_serve" => Self::JobServe, "text_trim" => Self::TextTrim, "text_lower" => Self::TextLower, "text_upper" => Self::TextUpper, "text_codepoint" => Self::TextCodepoint, "text_from_codepoint" => Self::TextFromCodepoint, "text_at" => Self::TextAt, "text_slice" => Self::TextSlice, "text_index_of" => Self::TextIndexOf, "text_contains" => Self::TextContains, "text_starts_with" => Self::TextStartsWith, "text_ends_with" => Self::TextEndsWith, "text_split" => Self::TextSplit, "text_replace" => Self::TextReplace, "int_parse" => Self::IntParse, "int_to_text" => Self::IntToText, "decimal_parse" => Self::DecimalParse, "decimal_to_text" => Self::DecimalToText, "decimal_from_int" => Self::DecimalFromInt, "float_parse" => Self::FloatParse, "float_to_text" => Self::FloatToText, "process_arguments" => Self::ProcessArguments, "crypto_token" => Self::CryptoToken, "crypto_password_hash" => Self::CryptoPasswordHash, "crypto_password_verify" => Self::CryptoPasswordVerify, "crypto_sha256" => Self::CryptoSha256, "crypto_hmac_sha256" => Self::CryptoHmacSha256, "crypto_constant_time_eq" => Self::CryptoConstantTimeEq, "time_unix_millis" => Self::TimeUnixMillis, "time_now" => Self::TimeNow, "time_parse_datetime" => Self::TimeParseDateTime, "time_format_datetime" => Self::TimeFormatDateTime, "time_parse_date" => Self::TimeParseDate, "time_format_date" => Self::TimeFormatDate, "time_parse_time" => Self::TimeParseTime, "time_format_time" => Self::TimeFormatTime, "time_duration" => Self::TimeDuration, "time_add" => Self::TimeAdd, "time_subtract" => Self::TimeSubtract, "time_difference" => Self::TimeDifference, "time_monotonic_nanos" => Self::TimeMonotonicNanos, "time_sleep" => Self::TimeSleep, "task_sleep" => Self::TaskSleep, "task_ticks" => Self::TaskTicks, "tls_system" => Self::TlsSystem, "tls_client" => Self::TlsClient, "tls_server" => Self::TlsServer, "http_client" => Self::HttpClientNew, "http_request" => Self::HttpRequest, "http_open" => Self::HttpOpen, "http_open_stream" => Self::HttpOpenStream, "http_close_client" => Self::HttpCloseClient, "http_serve_tls" => Self::HttpServeTls, "http_serve_live_tls" => Self::HttpServeLiveTls, "ws_open" => Self::WsOpen, "decimal_round" => Self::DecimalRound, "float_from_int" => Self::FloatFromInt, "float_sqrt" => Self::FloatSqrt, "float_sin" => Self::FloatSin, "float_cos" => Self::FloatCos, "float_log" => Self::FloatLog, "float_pow" => Self::FloatPow, "float_is_nan" => Self::FloatIsNan, "float_is_finite" => Self::FloatIsFinite, "float_is_infinite" => Self::FloatIsInfinite, "stdout_write" => Self::StdoutWrite, "log_debug" => Self::LogDebug, "log_info" => Self::LogInfo, "log_warn" => Self::LogWarn, "log_error" => Self::LogError, "id_from_text" => Self::IdFromText, "id_to_text" => Self::IdToText, "uuid_parse" => Self::UuidParse, "uuid_to_text" => Self::UuidToText, "bytes_from_text" => Self::BytesFromText, "bytes_to_text" => Self::BytesToText, "bytes_from_ints" => Self::BytesFromInts, "bytes_length" => Self::BytesLength, "bytes_at" => Self::BytesAt, "bytes_slice" => Self::BytesSlice, "bytes_concat" => Self::BytesConcat, "file_open" => Self::FileOpen, "file_create" => Self::FileCreate, "file_read" => Self::FileRead, "file_write" => Self::FileWrite, "file_close" => Self::FileClose, "file_chunks" => Self::FileChunks, "tcp_connect" => Self::TcpConnect, "tcp_connect_timeout" => Self::TcpConnectTimeout, "tcp_listen" => Self::TcpListen, "tcp_accept" => Self::TcpAccept, "tcp_port" => Self::TcpPort, "tcp_read" => Self::TcpRead, "tcp_write" => Self::TcpWrite, "tcp_timeout" => Self::TcpTimeout, "tcp_close" => Self::TcpClose, "tcp_close_listener" => Self::TcpCloseListener, "tcp_chunks" => Self::TcpChunks, "tcp_connections" => Self::TcpConnections, "http_serve" => Self::HttpServe, "api_serve" => Self::ApiServe, "api_request_id" => Self::ApiRequestId, "api_method" => Self::ApiMethod, "api_path" => Self::ApiPath, "api_client_address" => Self::ApiClientAddress, "api_header" => Self::ApiHeader, "api_cookie" => Self::ApiCookie, "api_secret_cookie" => Self::ApiSecretCookie, "api_response_header" => Self::ApiResponseHeader, "api_response_cookie" => Self::ApiResponseCookie, "api_response_secret_cookie" => Self::ApiResponseSecretCookie, "auth_issue" => Self::AuthIssue, "auth_issue_cookie" => Self::AuthIssueCookie, "auth_clear_cookie" => Self::AuthClearCookie, "auth_id" => Self::AuthId, "auth_session" => Self::AuthSession, "auth_user_id" => Self::AuthUserId, "auth_tenant_id" => Self::AuthTenantId, "auth_permissions" => Self::AuthPermissions, "auth_save_role" => Self::AuthSaveRole, "auth_grant_role" => Self::AuthGrantRole, "auth_revoke_role" => Self::AuthRevokeRole, "auth_disable_role" => Self::AuthDisableRole, "site_key" => Self::SiteKey, "http_send" => Self::HttpSend, "http_serve_live" => Self::HttpServeLive, "http_respond" => Self::HttpRespond, "http_start" => Self::HttpStart, "http_write" => Self::HttpWrite, "http_finish" => Self::HttpFinish, "sse_start" => Self::SseStart, "sse_send" => Self::SseSend, "ws_accept" => Self::WsAccept, "ws_connect" => Self::WsConnect, "ws_send" => Self::WsSend, "ws_receive" => Self::WsReceive, "ws_messages" => Self::WsMessages, "ws_close" => Self::WsClose, _ => return None, }) } }