mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
39 lines
825 B
Zig
39 lines
825 B
Zig
const std = @import("std");
|
|
|
|
const server = @import("../server.zig");
|
|
const Ctx = server.Cmd;
|
|
const cdp = @import("cdp.zig");
|
|
const result = cdp.result;
|
|
const getMsg = cdp.getMsg;
|
|
|
|
const Methods = enum {
|
|
disable,
|
|
};
|
|
|
|
pub fn fetch(
|
|
alloc: std.mem.Allocator,
|
|
id: ?u16,
|
|
action: []const u8,
|
|
scanner: *std.json.Scanner,
|
|
ctx: *Ctx,
|
|
) ![]const u8 {
|
|
const method = std.meta.stringToEnum(Methods, action) orelse
|
|
return error.UnknownMethod;
|
|
|
|
return switch (method) {
|
|
.disable => disable(alloc, id, scanner, ctx),
|
|
};
|
|
}
|
|
|
|
// TODO: noop method
|
|
fn disable(
|
|
alloc: std.mem.Allocator,
|
|
id: ?u16,
|
|
scanner: *std.json.Scanner,
|
|
_: *Ctx,
|
|
) ![]const u8 {
|
|
const msg = try getMsg(alloc, void, scanner);
|
|
|
|
return result(alloc, id orelse msg.id.?, null, null, msg.sessionID);
|
|
}
|