feat: Clarify number types for strictly-typed languages such as Rust

Co-authored-by: April John <30842467+CutestNekoAqua@users.noreply.github.com>
This commit is contained in:
Jesse Wierzbinski 2024-05-13 08:36:37 -10:00
parent 4f412a2e32
commit 79d1524af0
No known key found for this signature in database
5 changed files with 18 additions and 12 deletions

View file

@ -226,7 +226,7 @@ The server **MAY** send a `GET` request to the poll's Publication URI to update
interface Poll extends Extension {
extension_type: "org.lysand:polls/Poll";
options: ContentFormat[];
votes: number[];
votes: number[]; // unsigned 64-bit integer
multiple_choice?: boolean;
expires_at: string;
}
@ -236,7 +236,7 @@ interface Poll extends Extension {
interface Vote extends Extension {
extension_type: "org.lysand:polls/Vote";
poll: string;
option: number;
option: number; // unsigned 64-bit integer
}
```
@ -244,6 +244,6 @@ interface Vote extends Extension {
interface VoteResult extends Extension {
extension_type: "org.lysand:polls/VoteResult";
poll: string;
votes: number[];
votes: number[]; // unsigned 64-bit integer
}
```

View file

@ -295,7 +295,7 @@ interface Publication extends Entity {
"org.lysand:polls"?: {
poll: {
options: ContentFormat[];
votes: number[];
votes: number[]; // unsigned 64-bit integer
multiple_choice?: boolean;
expires_at: string;
};

View file

@ -34,6 +34,14 @@ The words **MUST**, **MUST NOT**, **SHOULD**, **SHOULD NOT**, and **MAY** are us
Servers **MUST** reject any requests that fail to respect the Lysand specification in any way. This includes, but is not limited to, incorrect JSON object handling, incorrect HTTP headers, and incorrect URI normalization.
## For strictly-typed languages (e.g. Rust)
All numbers are to be treated as 64-bit integer or floats (depending on whether a valid value would be int or float). If a valid value cannot be negative, it must also be treated as unsigned.
Examples:
- A `size` (bytes) property on a file object should be treated as an unsigned 64-bit integer.
- A `duration` property on a video object should be treated as an unsigned 64-bit float.
## HTTP
All HTTP request and response bodies **MUST** be encoded as UTF-8 JSON, with the `Content-Type` header set to `application/json; charset=utf-8`. Appropriate signatures must be included in the `Signature` header for **every request and response**.

View file

@ -8,7 +8,7 @@ Here's how a Collections can be represented in TypeScript:
interface Collections<T> {
first: string;
last: string;
total_count: number;
total_count: number; // unsigned 64-bit integer
author: string;
next?: string;
prev?: string;

View file

@ -7,19 +7,17 @@ interface ContentFormat {
[contentType: string]: {
content: string;
description?: string;
size?: number;
size?: number; // unsigned 64-bit integer
hash?: {
md5?: string;
sha1?: string;
sha256?: string;
sha512?: string;
[key: string]: string | undefined;
};
blurhash?: string;
fps?: number;
width?: number;
height?: number;
duration?: number;
fps?: number; // unsigned 64-bit integer
width?: number; // unsigned 64-bit integer
height?: number; // unsigned 64-bit integer
duration?: number; // unsigned 64-bit integer
}
}
```