distribute/codec
Types
Encoder + decoder + sized decoder, bundled.
pub type Codec(a) {
Codec(
encoder: fn(a) -> Result(BitArray, EncodeError),
decoder: fn(BitArray) -> Result(a, DecodeError),
sized_decoder: fn(BitArray) -> Result(
#(a, BitArray),
DecodeError,
),
)
}
Constructors
-
Codec( encoder: fn(a) -> Result(BitArray, EncodeError), decoder: fn(BitArray) -> Result(a, DecodeError), sized_decoder: fn(BitArray) -> Result( #(a, BitArray), DecodeError, ), )
pub type DecodeError {
InvalidBinary(String)
TypeMismatch(String)
DecodeFailed(String)
InsufficientData(String)
DecodeTimeout
TagMismatch(expected: String, got: String)
VersionMismatch(expected: Int, got: Int)
}
Constructors
-
InvalidBinary(String) -
TypeMismatch(String) -
DecodeFailed(String) -
InsufficientData(String) -
DecodeTimeout -
TagMismatch(expected: String, got: String) -
VersionMismatch(expected: Int, got: Int)
pub type Decoder(a) =
fn(BitArray) -> Result(a, DecodeError)
pub type EncodeError {
InvalidValue(String)
EncodeFailed(String)
ValueTooLarge(String)
}
Constructors
-
InvalidValue(String) -
EncodeFailed(String) -
ValueTooLarge(String)
pub type Encoder(a) =
fn(a) -> Result(BitArray, EncodeError)
Like Decoder but returns leftover bytes for chaining.
pub type SizedDecoder(a) =
fn(BitArray) -> Result(#(a, BitArray), DecodeError)
Values
pub fn bitarray_decoder() -> fn(BitArray) -> Result(
BitArray,
DecodeError,
)
pub fn bitarray_encoder() -> fn(BitArray) -> Result(
BitArray,
EncodeError,
)
pub fn bitarray_sized_decoder() -> fn(BitArray) -> Result(
#(BitArray, BitArray),
DecodeError,
)
pub fn bool_decoder() -> fn(BitArray) -> Result(Bool, DecodeError)
pub fn bool_encoder() -> fn(Bool) -> Result(BitArray, EncodeError)
pub fn bool_sized_decoder() -> fn(BitArray) -> Result(
#(Bool, BitArray),
DecodeError,
)
pub fn decode(
decoder: fn(BitArray) -> Result(a, DecodeError),
data: BitArray,
) -> Result(a, DecodeError)
pub fn decode_error_to_string(error: DecodeError) -> String
pub fn decode_sized(
decoder: fn(BitArray) -> Result(#(a, BitArray), DecodeError),
data: BitArray,
) -> Result(#(a, BitArray), DecodeError)
pub fn encode(
encoder: fn(a) -> Result(BitArray, EncodeError),
value: a,
) -> Result(BitArray, EncodeError)
pub fn encode_error_to_string(error: EncodeError) -> String
pub fn float_decoder() -> fn(BitArray) -> Result(
Float,
DecodeError,
)
pub fn float_encoder() -> fn(Float) -> Result(
BitArray,
EncodeError,
)
pub fn float_sized_decoder() -> fn(BitArray) -> Result(
#(Float, BitArray),
DecodeError,
)
pub fn int_decoder() -> fn(BitArray) -> Result(Int, DecodeError)
pub fn int_encoder() -> fn(Int) -> Result(BitArray, EncodeError)
pub fn int_sized_decoder() -> fn(BitArray) -> Result(
#(Int, BitArray),
DecodeError,
)
pub fn list_decoder(
element_decoder: fn(BitArray) -> Result(
#(a, BitArray),
DecodeError,
),
) -> fn(BitArray) -> Result(List(a), DecodeError)
pub fn list_encoder(
element_encoder: fn(a) -> Result(BitArray, EncodeError),
) -> fn(List(a)) -> Result(BitArray, EncodeError)
pub fn list_sized_decoder(
element_decoder: fn(BitArray) -> Result(
#(a, BitArray),
DecodeError,
),
) -> fn(BitArray) -> Result(#(List(a), BitArray), DecodeError)
pub fn map(
c: Codec(a),
wrap: fn(a) -> b,
unwrap: fn(b) -> a,
) -> Codec(b)
Transform a codec. wrap runs after decoding, unwrap before encoding.
pub fn nil_decoder() -> fn(BitArray) -> Result(Nil, DecodeError)
pub fn nil_encoder() -> fn(Nil) -> Result(BitArray, EncodeError)
pub fn nil_sized_decoder() -> fn(BitArray) -> Result(
#(Nil, BitArray),
DecodeError,
)
pub fn string_decoder() -> fn(BitArray) -> Result(
String,
DecodeError,
)
pub fn string_encoder() -> fn(String) -> Result(
BitArray,
EncodeError,
)
pub fn string_sized_decoder() -> fn(BitArray) -> Result(
#(String, BitArray),
DecodeError,
)
pub fn subject() -> Codec(process.Subject(BitArray))
Subject codec, for the request/response pattern.
pub fn subject_decoder() -> fn(BitArray) -> Result(
process.Subject(BitArray),
DecodeError,
)
pub fn subject_encoder() -> fn(process.Subject(BitArray)) -> Result(
BitArray,
EncodeError,
)
Encode a Subject(BitArray) via term_to_binary. The PID inside carries node info, so it routes back cross-node.
pub fn subject_sized_decoder() -> fn(BitArray) -> Result(
#(process.Subject(BitArray), BitArray),
DecodeError,
)
pub fn to_decoder(
sized: fn(BitArray) -> Result(#(a, BitArray), DecodeError),
) -> fn(BitArray) -> Result(a, DecodeError)
Turn a SizedDecoder into a Decoder (drops remaining bytes).