Function parse_payload_type
pub fn parse_payload_type(value: &[u8]) -> Result<&str, CratestackError>Expand description
Parse a received PAYLOAD_TYPE_HEADER value, strictly.
Checks the grammar only; whether the type may be sealed or is allowed for
an op is the caller’s decision (is_sealable_payload_type, the op’s
declared types).
use cratestack_core::parse_payload_type;
assert_eq!(
parse_payload_type(b"application/x-www-form-urlencoded").unwrap(),
"application/x-www-form-urlencoded"
);
assert!(parse_payload_type(b"Application/JSON").is_err());
assert!(parse_payload_type(b"application/json; charset=utf-8").is_err());