summaryrefslogtreecommitdiff
path: root/src/response.zig
blob: 8964de4118a134b44b4dd78a45f488159fbc4182 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const std = @import("std");
const Request = @import("request.zig");
const Types = @import("types.zig");

pub const Response = @This();

pub const TorrentGet = struct {
    pub const Arguments = struct {
        torrents: ?[]Types.Torrent = null,
    };

    result: []const u8,
    arguments: Arguments,
};

pub const Object = struct {
    pub const Arguments = union(Request.Method) {
        torrent_start,
        torrent_start_now,
        torrent_stop,
        torrent_verify,
        torrent_reannounce,
        torrent_set,
        torrent_get: TorrentGet.Arguments,
        torrent_add,
        torrent_remove,
        torrent_set_location,
        torrent_rename_path,
        session_get,
        session_set,
    };

    result: []const u8,
    arguments: Arguments,

    pub fn init(arguments: Arguments, result: []const u8) Object {
        switch (arguments) {
            .torrent_get => {
                return Object{
                    .result = result,
                    .arguments = arguments,
                };
            },
            else => unreachable,
        }
    }
};