pub trait HasStateEntry
where Self: Read + Write<Err = Self::Error> + Seek<Err = Self::Error>,
{ type StateEntryData; type StateEntryKey; type Error: Default; // Required methods fn move_to_start(&mut self); fn size(&self) -> Result<u32, Self::Error>; fn truncate(&mut self, new_size: u32) -> Result<(), Self::Error>; fn get_key(&self) -> &[u8] ; fn resize(&mut self, new_size: u32) -> Result<(), Self::Error>; // Provided method fn reserve(&mut self, len: u32) -> Result<(), Self::Error> { ... } }
Expand description

A type that can serve as the contract state entry type.

§Deprecation notice

This trait is deprecated along with crate::test_infrastructure.

Use StateEntry instead unless you intend to use the deprecated test infrastructure.

See the crate documentation for more details.

Required Associated Types§

Required Methods§

source

fn move_to_start(&mut self)

Set the cursor to the beginning. Equivalent to .seek(SeekFrom::Start(0)) but can be implemented more efficiently.

source

fn size(&self) -> Result<u32, Self::Error>

Get the current size of the entry. Returns an error if the entry does not exist.

source

fn truncate(&mut self, new_size: u32) -> Result<(), Self::Error>

Truncate the entry to the given size. If the given size is more than the current size this operation does nothing. The new position is at most at the end of the stream. Returns an error if the entry does not exist.

source

fn get_key(&self) -> &[u8]

Get a reference to the entry’s key.

source

fn resize(&mut self, new_size: u32) -> Result<(), Self::Error>

Resize the entry to the given size. Returns an error if the entry does not exist.

Provided Methods§

source

fn reserve(&mut self, len: u32) -> Result<(), Self::Error>

Make sure that the memory size is at least that many bytes in size. Returns Ok iff this was successful. The new bytes are initialized as 0. Returns an error if the entry does not exist.

Object Safety§

This trait is not object safe.

Implementors§