tiny.sandbox.backend
Defined in tiny.sandbox.
API (3)
Actions
Public operations.
Types and contracts
Public types and contracts.
Source
Source: lib/sandbox/src/backend.zig
zig
const std = @import("std");pub const Policy = enum { require_strongest, prefer_strongest, portable_only,};pub fn policyFromName(value: []const u8) ?Policy { if (nameMatches(value, "require-strongest")) return .require_strongest; if (nameMatches(value, "require_strongest")) return .require_strongest; if (nameMatches(value, "prefer-strongest")) return .prefer_strongest; if (nameMatches(value, "prefer_strongest")) return .prefer_strongest; if (nameMatches(value, "portable-only")) return .portable_only; if (nameMatches(value, "portable_only")) return .portable_only; return null;}pub fn policyName(value: Policy) []const u8 { return switch (value) { .require_strongest => "require-strongest", .prefer_strongest => "prefer-strongest", .portable_only => "portable-only", };}fn nameMatches(value: []const u8, name: []const u8) bool { return std.ascii.eqlIgnoreCase(value, name);}test "backend policy parses setting names" { try std.testing.expectEqual(Policy.require_strongest, policyFromName("require-strongest").?); try std.testing.expectEqual(Policy.require_strongest, policyFromName("require_strongest").?); try std.testing.expectEqual(Policy.prefer_strongest, policyFromName("PREFER-STRONGEST").?); try std.testing.expectEqual(Policy.portable_only, policyFromName("portable-only").?); try std.testing.expectEqualStrings("portable-only", policyName(.portable_only)); try std.testing.expect(policyFromName("strong") == null);}Source: lib/sandbox/src/root.zig:29
zig
pub const backend = @import("backend.zig");Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |