glyde/rest/image
Images going up on an avatar, banner or icon field.
Discord returns a hash on those fields and takes a base64 data URI, so a
decoded avatar is not something you can send back. This is a separate
type built from bytes, which is what keeps the two apart.
Discord accepts JPG, PNG and GIF.
Types
data:<mime>;base64,<bytes>, the only form the image fields take.
pub opaque type ImageData
Why bytes are not an image Discord takes.
pub type UnsupportedImage {
ImageEmpty
UnknownFormat
}
Constructors
-
ImageEmpty -
UnknownFormatThe bytes start with none of the three signatures.
Values
pub fn from_bytes(
data: BitArray,
) -> Result(ImageData, UnsupportedImage)
The mime label comes off the bytes, so a caller cannot promise a PNG and send something else. Discord answers 400 to anything but JPG, PNG and GIF, which is what the three signatures below cover.