aboutsummaryrefslogtreecommitdiff
path: root/src/install/versioned_url.zig
blob: bf510b54512ac9d859be2f91c705ec4546971a56 (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
const Semver = @import("./semver.zig");
const String = @import("./semver.zig").String;

pub const VersionedURL = extern struct {
    url: String,
    version: Semver.Version,

    pub fn eql(this: VersionedURL, other: VersionedURL) bool {
        return this.version.eql(other.version);
    }

    pub fn order(this: VersionedURL, other: VersionedURL, lhs_buf: []const u8, rhs_buf: []const u8) @import("std").math.Order {
        return this.version.order(other.version, lhs_buf, rhs_buf);
    }

    pub fn fmt(this: VersionedURL, buf: []const u8) Semver.Version.Formatter {
        return this.version.fmt(buf);
    }

    pub fn count(this: VersionedURL, buf: []const u8, comptime Builder: type, builder: Builder) void {
        this.version.count(buf, comptime Builder, builder);
        builder.count(this.url.slice(buf));
    }

    pub fn clone(this: VersionedURL, buf: []const u8, comptime Builder: type, builder: Builder) VersionedURL {
        return VersionedURL{
            .version = this.version.clone(buf, Builder, builder),
            .url = builder.append(String, this.url.slice(buf)),
        };
    }
};