tiny.wayland.protocol.value.validate
Defined in protocol.value.
API (1)
Actions
Public operations.
Source
Source: lib/wayland/src/protocol/value/root.zig:5
zig
pub const validate = @import("validate.zig");Source: lib/wayland/src/protocol/value/validate.zig
zig
const decode = @import("decode.zig");const protocol = @import("../root.zig");pub fn message( metadata: *const protocol.schema.Message, payload: []const u8, descriptors: []const @import("sys").fd.Descriptor,) decode.Error!void { var decoder = try decode.Decoder.init(metadata, payload, descriptors); var optional = false; for (metadata.signature) |symbol| switch (symbol) { '0'...'9' => {}, '?' => optional = true, 'i' => { _ = try decoder.signed(); optional = false; }, 'u' => { _ = try decoder.unsigned(); optional = false; }, 'f' => { _ = try decoder.fixed(); optional = false; }, 's' => { if (optional) { _ = try decoder.optionalString(); } else { _ = try decoder.string(); } optional = false; }, 'o' => { if (optional) { _ = try decoder.optionalObject(); } else { _ = try decoder.object(); } optional = false; }, 'n' => { _ = try decoder.newId(); optional = false; }, 'a' => { _ = try decoder.array(); optional = false; }, 'h' => { _ = try decoder.descriptor(); optional = false; }, else => unreachable, }; if (optional) unreachable; try decoder.finish();}test "generic validation follows expanded scanner signatures" { const std = @import("std"); const encode = @import("encode.zig"); const bind = &protocol.core.wl_registry.requests.bind; var encoder = try encode.Encoder.init(std.testing.allocator, encode.default_capacity); defer encoder.deinit(); try encoder.unsigned(4); try encoder.dynamicNewId("wl_output", 3, try .init(9)); const encoded = try encoder.finish(bind); try message(bind, encoded.payload, encoded.descriptors); try std.testing.expectError( error.IncompletePayload, message(bind, encoded.payload[0 .. encoded.payload.len - 4], encoded.descriptors), );}test "generic validation applies nullable wire modifiers" { const metadata: protocol.schema.Message = .{ .name = "nullable", .opcode = 0, .since = 1, .deprecated_since = null, .destructor = false, .signature = "?s?o", .descriptor_count = 0, .minimum_payload_size = 8, .arguments = &.{}, }; try message(&metadata, &(@as([8]u8, @splat(0))), &.{});}Complete call list for protocol.value.validate.message
10 direct calls.
tiny.wayland.protocol.value.Decoder.array[method] atlib/wayland/src/protocol/value/decode.zig:101tiny.wayland.protocol.value.Decoder.descriptor[method] atlib/wayland/src/protocol/value/decode.zig:105tiny.wayland.protocol.value.Decoder.init[function] atlib/wayland/src/protocol/value/decode.zig:31tiny.wayland.protocol.value.Decoder.newId[method] atlib/wayland/src/protocol/value/decode.zig:85tiny.wayland.protocol.value.Decoder.object[method] atlib/wayland/src/protocol/value/decode.zig:76tiny.wayland.protocol.value.Decoder.optionalObject[method] atlib/wayland/src/protocol/value/decode.zig:80tiny.wayland.protocol.value.Decoder.optionalString[method] atlib/wayland/src/protocol/value/decode.zig:65tiny.wayland.protocol.value.Decoder.signed[method] atlib/wayland/src/protocol/value/decode.zig:47tiny.wayland.protocol.value.Decoder.string[method] atlib/wayland/src/protocol/value/decode.zig:61tiny.wayland.protocol.value.Decoder.unsigned[method] atlib/wayland/src/protocol/value/decode.zig:52
Audit
| Definitions | 2 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |