pub trait Register {
    fn name(&self) -> &str;
    fn access(&self) -> Access;
    fn read(&self) -> Value;
    fn write(&mut self, value: &Value) -> Result<(), WriteError>;
}
Expand description

A register that can be read and optionally written

Required methods

Returns the name of this register

The name must not be more than 256 bytes long. Each register must have a distinct name.

Returns information about how this register can be accessed

Reads this register and returns its value

This function must not return Value::Empty.

Writes the value of this register

This function may be used on a register that is both persistent and mutable to load its value from persistent storage.

Outside code must not call this function in response to a write request from another node if this register is not mutable.

This function returns an error if the provided value does not have an appropriate type for this register.

If this function returns an error, the value of this register must be the same as before the call to write().

Panics

This function may panic if self.access() returned a value with mutable set to false.

Implementors