mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Add method cdp function
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -52,11 +52,11 @@ pub fn do(
|
||||
const id = try std.fmt.parseUnsigned(u64, (try scanner.next()).number, 10);
|
||||
|
||||
try checkKey("method", (try scanner.next()).string);
|
||||
const method = (try scanner.next()).string;
|
||||
const method_name = (try scanner.next()).string;
|
||||
|
||||
std.log.debug("cmd: id {any}, method {s}", .{ id, method });
|
||||
std.log.debug("cmd: id {any}, method {s}", .{ id, method_name });
|
||||
|
||||
var iter = std.mem.splitScalar(u8, method, '.');
|
||||
var iter = std.mem.splitScalar(u8, method_name, '.');
|
||||
const domain = std.meta.stringToEnum(Domains, iter.first()) orelse
|
||||
return error.UnknonwDomain;
|
||||
|
||||
@@ -121,6 +121,24 @@ pub fn result(
|
||||
return stringify(alloc, resp);
|
||||
}
|
||||
|
||||
// caller owns the slice returned
|
||||
pub fn method(
|
||||
alloc: std.mem.Allocator,
|
||||
name: []const u8,
|
||||
comptime T: type,
|
||||
params: T,
|
||||
sessionID: ?[]const u8,
|
||||
) ![]const u8 {
|
||||
const Resp = struct {
|
||||
method: []const u8,
|
||||
params: T,
|
||||
sessionId: ?[]const u8,
|
||||
};
|
||||
const resp = Resp{ .method = name, .params = params, .sessionId = sessionID };
|
||||
|
||||
return stringify(alloc, resp);
|
||||
}
|
||||
|
||||
pub fn getParams(
|
||||
alloc: std.mem.Allocator,
|
||||
comptime T: type,
|
||||
|
||||
Reference in New Issue
Block a user