pub trait MinimalWritableMessage {
    type Code: Code;
    type OptionNumber: OptionNumber;

    fn set_code(&mut self, code: Self::Code);
    fn add_option(&mut self, number: Self::OptionNumber, value: &[u8]);
    fn set_payload(&mut self, data: &[u8]);

    fn set_from_message<M>(&mut self, msg: &M)
   where
        M: ReadableMessage
, { ... } fn add_option_str(&mut self, number: Self::OptionNumber, value: &str) { ... } fn add_option_uint<U: Ux>(&mut self, number: Self::OptionNumber, value: U) { ... } }
Expand description

A message that needs to have its code, any options in ascending order and its payload set in that very sequence.

This is the bare minimum a message needs to provide to be populated as a request or response by a generic program; it is up to the program to ensure the valid sequence of operations, as failure to do so may incur panics (FIXME: or errors).

Required Associated Types

Required Methods

Add an option to the message

Calls to this method need to happen in ascending numeric sequence.

This works on option values as they are encoded in messages. Under the aspect of option value formats, this adds opaque options (but may just as well be used for adding options in another format when they are pre-encoded).

Provided Methods

Copy code, options and payload in from a readable message

Implementations can override this for cases where it can be done more efficiently than iterating over the options and appending them.

Shortcut for add_option(self, number, value.as_bytes()).

Implementations with type checked options can provide more efficient implementations (ie. ones that don’t need to UTF-8-check when they feed the resulting bytes back into a string field), but must still accept string options via the generic add_option() method.

Shortcut for add_option on a buffer containing the uint encoded value

Implementations with type checked options can provide more efficient implementations (ie. ones that don’t need to decode the uint when reading it into a uint field), but must still accept integer options via the generic add_option() method.

While the trait under U is hidden (pending the use of a more generic one num-types based one), own implementations are not possible.

Implementors