identity_iota_client/tangle/message/
message_encoding.rs

1// Copyright 2020-2021 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use num_traits::FromPrimitive;
5
6use crate::Error;
7
8/// Indicates the encoding and compression of a DID Message.
9#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, num_derive::FromPrimitive)]
10pub enum DIDMessageEncoding {
11  Json = 0,
12  JsonBrotli = 1,
13}
14
15impl TryFrom<u8> for DIDMessageEncoding {
16  type Error = Error;
17
18  fn try_from(value: u8) -> Result<Self, Self::Error> {
19    FromPrimitive::from_u8(value).ok_or(Error::InvalidMessageFlags)
20  }
21}