Crate extra_safe
source ·Expand description
An exploration of type-level SAFE.
This software is in a very early stage of development. We do not advise depending on it, yet.
EXTRA-SAFE
This applies typestate-oriented programming techniques in Rust, along with type-level programming in order of make SAFE APIs even more safe.
At a basic level, the SAFE API is meant to return errors at runtime when the user makes a mistake in its usage. This crate aims to lift most of those errors at compile time.
License
MIT This crate offers a method and a set of traits that lifts the errors produces by the Sponge API at runtime. To read more about the Sponge API, you can read the Spec at this link.
Modules
This module contains the traits for the IOPattern type, along with the implementation of type-level operations checking on their correct usage.
The IOPattern type is a type-level HList of IOWords, which are either Absorb or Squeeze.
The main operations are Normalize, which merges successive words of the same type, and Consume, which takes a word and an IOPattern, and checks whether
it is legal to use the operation of this word on the tip of the IOPattern.
This is explained in more detail in the spec document.
Macros
Convenience helper for creating an instance of List
Structs
This is a slightly extended generic NewType wrapper around the original SpongeAPI.
It is decorated with the IOPattern I intended for this sponge instance.
The type describing the I/O pattern of a sponge, at a term level.
Enums
The Error returned at runtime by the sponge API in case the finalize operation fails.
The SpongeWord type is lifted straight from the Neptune codebase.
See
<https://github.com/filecoin-project/neptune/blob/master/src/sponge/api.rs>Traits
This is the SpongeAPI trait as you can find it in Neptune,
see
<https://github.com/filecoin-project/neptune/blob/master/src/sponge/api.rs>
Slightly modified so that the squeeze function takes an argument as a mutable slice
instead of returning a Vec.Conversion from a trait::List type-level IOPattern to a crate::IOpattern
This is morally an extension trait of the List trait, though Rust can of
course not check exhaustivity.
Conversion from a type-level IOWord to a crate::SpongeOp
This is, morally speaking, an extension trait of the IOWord trait,
though Rust can of course not check exhaustivity.