From c7412022c3c607c809f774db2459f9259ba95038 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sat, 17 Jun 2023 02:54:34 +0200 Subject: one step closer --- src/types.zig | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 src/types.zig (limited to 'src/types.zig') diff --git a/src/types.zig b/src/types.zig new file mode 100644 index 0000000..b8029ca --- /dev/null +++ b/src/types.zig @@ -0,0 +1,189 @@ +// types are from: +// https://github.com/transmission/transmission/blob/76166d8fa71f351fe46221d737f8849b23f551f7/libtransmission/transmission.h#L1604 +// where: +// time_t => i64 +// float => f32 +// uint16_t => u16 +pub const Torrent = struct { + // The last time we uploaded or downloaded piece data on this torrent. + activityDate: ?i64 = null, + + // When the torrent was first added. + addedDate: ?i64 = null, + + //availability: []struct {}, array (see below) tr_torrepieceCountntAvailability() + + //bandwidthPriority: ?usize = null, + comment: ?[]u8 = null, + + // Byte count of all the corrupt data you've ever downloaded for + // this torrent. If you're on a poisoned torrent, this number can + // grow very large. + corruptEver: ?u64 = null, + + creator: ?[]u8 = null, + //dateCreated: ?usize = null, + + // Byte count of all the piece data we want and don't have yet, + // but that a connected peer does have. + desiredAvailable: ?u64 = null, + + // When the torrent finished downloading. + doneDate: ?i64 = null, + + downloadDir: ?[]u8 = null, + + // Byte count of all the non-corrupt data you've ever downloaded + // for this torrent. If you deleted the files and downloaded a second + // time, this will be `2*totalSize`. + downloadedEver: ?u64 = null, + + //downloadLimit: ?usize = null, + downloadLimited: ?bool = null, + + // The last time during this session that a rarely-changing field + // changed -- e.g. fields like trackers, filenames, name + // or download directory. RPC clients can monitor this to know when + // to reload fields that rarely change. + editDate: ?i64 = null, + + //@"error": ?usize = null, + errorString: ?[]u8 = null, + + // If downloading, estimated number of seconds left until the torrent is done. + // If seeding, estimated number of seconds left until seed ratio is reached. + eta: ?i64 = null, + + // If seeding, number of seconds left until the idle time limit is reached. + etaIdle: ?i64 = null, + + //@"file-count": ?usize = null, + ////files array (see below) n/a + ////fileStats array (see below) n/a + group: ?[]u8 = null, + hashString: ?[]u8 = null, + + // Byte count of all the partial piece data we have for this torrent. + // As pieces become complete, this value may decrease as portions of it + // are moved to `corrupt` or `haveValid`. + haveUnchecked: ?u64 = null, + + // Byte count of all the checksum-verified data we have for this torrent. + haveValid: ?u64 = null, + + honorsSessionLimits: ?bool = null, + + id: ?i32 = null, + + isFinished: ?bool = null, + isPrivate: ?bool = null, + isStalled: ?bool = null, + labels: ?[][]u8 = null, + + // Byte count of how much data is left to be downloaded until we've got + // all the pieces that we want. + leftUntilDone: ?u64 = null, + + magnetLink: ?[]u8 = null, + //manualAnnounceTime: ?usize = null, + //maxConnectedPeers: ?usize = null, + + // How much of the metadata the torrent has. + // For torrents added from a torrent this will always be 1. + // For magnet links, this number will from from 0 to 1 as the metadata is downloaded. + // Range is [0..1] + metadataPercentComplete: ?f32 = null, + + name: ?[]u8 = null, + //@"peer-limit": ?usize = null, + ////peers array (see below) n/a + + // Number of peers that we're connected to + peersConnected: ?u16 = null, + + ////peersFrom object (see below) n/a + + // Number of peers that we're sending data to. + peersGettingFromUs: ?u16 = null, + + // Number of peers that are sending data to us. + peersSendingToUs: ?u16 = null, + + // How much has been downloaded of the entire torrent. + // Range is [0..1] + percentComplete: ?f32 = null, + + // How much has been downloaded of the files the user wants. This differs + // from percentComplete if the user wants only some of the torrent's files. + // Range is [0..1] + // See `leftUntilDone` + percentDone: ?f32 = null, + + pieces: ?[]u8 = null, + //pieceCount: ?usize = null, + //pieceSize: ?usize = null, + ////priorities array (see below) n/a + @"primary-mime-type": ?[]u8 = null, + + // This torrent's queue position. + // All torrents have a queue position, even if it's not queued. + queuePosition: ?usize = null, + + //@"rateDownload (B/s)": ?usize = null, + //@"rateUpload (B/s)": ?usize = null, + + // When `tr_stat.activity` is `TR_STATUS_CHECK` or `TR_STATUS_CHECK_WAIT`, + // this is the percentage of how much of the files has been + // verified. When it gets to 1, the verify process is done. + // Range is [0..1] + // @see `tr_stat.activity` + recheckProgress: ?f32 = null, + + // Number of seconds since the last activity (or since started). + // -1 if activity is not seeding or downloading. + secondsDownloading: ?f32 = null, + + // Cumulative seconds the torrent's ever spent seeding. + secondsSeeding: ?f32 = null, + + //seedIdleLimit: ?usize = null, + //seedIdleMode: ?usize = null, + + // ?? + seedRatioLimit: ?f32 = null, + + //seedRatioMode: ?usize = null, + sequentialDownload: ?bool = null, + + // Byte count of all the piece data we'll have downloaded when we're done, + // whether or not we have it yet. This may be less than `totalSize` + // if only some of the torrent's files are wanted. + sizeWhenDone: ?u64 = null, + + // When the torrent was last started. + startDate: ?i64 = null, + + //status: ?usize = null, + ////trackers array (see below) n/a + trackerList: ?[]u8 = null, + ////trackerStats array (see below) n/a + //totalSize: ?usize = null, + torrentFile: ?[]u8 = null, + + // Byte count of all data you've ever uploaded for this torrent. + uploadedEver: ?u64 = null, + + //uploadLimit: ?usize = null, + uploadLimited: ?bool = null, + + // ?? + uploadRatio: ?f32 = null, + + ////wanted array (see below) n/a + + // ?? + webseeds: ?[][]u8 = null, + + // Number of webseeds that are sending data to us. + webseedsSendingToUs: ?u16 = null, +}; -- cgit v1.2.3