oaspec/util/content_type
Types
Supported content types for code generation.
pub type ContentType {
ApplicationJson
TextPlain
MultipartFormData
FormUrlEncoded
ApplicationOctetStream
ApplicationXml
TextXml
UnsupportedContentType(String)
}
Constructors
-
ApplicationJson -
TextPlain -
MultipartFormData -
FormUrlEncoded -
ApplicationOctetStream -
ApplicationXml -
TextXml -
UnsupportedContentType(String)
Values
pub fn from_string(content_type: String) -> ContentType
Parse a content type string into a ContentType.
Recognizes structured syntax suffixes: types ending with +json are
treated as JSON-compatible, and types ending with +xml as XML-compatible.
pub fn is_json_compatible(s: String) -> Bool
Check if a content type string is JSON-compatible. Matches “application/json” and any type with a “+json” suffix.
pub fn is_supported(content_type: ContentType) -> Bool
Check if a content type is supported anywhere in code generation.
pub fn is_supported_request(content_type: ContentType) -> Bool
Check if a content type is supported for request bodies.
Driven by the capability registry: looks up the MIME string under
category "request" at level Supported. UnsupportedContentType
never matches the registry and always returns False.
pub fn is_supported_response(content_type: ContentType) -> Bool
Check if a content type is supported for responses. Same mechanism
as is_supported_request, just targeting the "response" category.
pub fn is_xml_compatible(s: String) -> Bool
Check if a content type string is XML-compatible. Matches “application/xml”, “text/xml”, and any type with a “+xml” suffix.
pub fn to_string(content_type: ContentType) -> String
Convert a ContentType back to its string representation.