mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-03-11 12:52:23 +00:00
generate docs for a lot of API (test try)
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
package dev.inmo.micro_utils.mime_types
|
||||
|
||||
/**
|
||||
* A custom implementation of [MimeType] that wraps a raw MIME type string.
|
||||
* Use this when you need to work with MIME types that aren't defined in the standard set.
|
||||
*
|
||||
* @param raw The raw MIME type string (e.g., "application/custom", "text/x-custom")
|
||||
*/
|
||||
data class CustomMimeType(override val raw: String) : MimeType
|
||||
|
||||
@@ -2,9 +2,24 @@ package dev.inmo.micro_utils.mime_types
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Represents a MIME type (Multipurpose Internet Mail Extensions type).
|
||||
* A MIME type is a standard way to indicate the nature and format of a document, file, or assortment of bytes.
|
||||
*
|
||||
* Examples: "text/html", "application/json", "image/png"
|
||||
*/
|
||||
@Serializable(MimeTypeSerializer::class)
|
||||
interface MimeType {
|
||||
/**
|
||||
* The raw MIME type string (e.g., "text/html", "application/json").
|
||||
*/
|
||||
val raw: String
|
||||
|
||||
/**
|
||||
* An array of file extensions commonly associated with this MIME type.
|
||||
* For example, "text/html" might have extensions ["html", "htm"].
|
||||
* Returns an empty array by default if no extensions are known.
|
||||
*/
|
||||
val extensions: Array<String>
|
||||
get() = emptyArray()
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* Serializer for [MimeType] that serializes MIME types as their raw string representation.
|
||||
* Uses the [mimeType] factory function to create appropriate [MimeType] instances during deserialization,
|
||||
* which will return known MIME types when available or create [CustomMimeType] for unknown types.
|
||||
*/
|
||||
@Suppress("OPT_IN_USAGE")
|
||||
@Serializer(MimeType::class)
|
||||
object MimeTypeSerializer : KSerializer<MimeType> {
|
||||
|
||||
Reference in New Issue
Block a user