pub struct Predicate {
pub state_read: Vec<StateReadBytecode>,
pub constraints: Vec<ConstraintBytecode>,
}
Expand description
An individual predicate to be solved.
Fields§
§state_read: Vec<StateReadBytecode>
The programs that read state.
constraints: Vec<ConstraintBytecode>
The programs that check constraints.
Implementations§
Source§impl Predicate
impl Predicate
Sourcepub const MAX_STATE_READS: usize = 255usize
pub const MAX_STATE_READS: usize = 255usize
Maximum number of state read programs of a predicate.
Sourcepub const MAX_STATE_READ_SIZE_BYTES: usize = 10_000usize
pub const MAX_STATE_READ_SIZE_BYTES: usize = 10_000usize
Maximum size of state read programs of a predicate in bytes.
Sourcepub const MAX_CONSTRAINTS: usize = 255usize
pub const MAX_CONSTRAINTS: usize = 255usize
Maximum number of constraint check programs of a predicate.
Sourcepub const MAX_CONSTRAINT_SIZE_BYTES: usize = 10_000usize
pub const MAX_CONSTRAINT_SIZE_BYTES: usize = 10_000usize
Maximum size of constraint check programs of a predicate in bytes.
Sourcepub fn programs(&self) -> impl Iterator<Item = &[u8]>
pub fn programs(&self) -> impl Iterator<Item = &[u8]>
Iterator over the programs in the predicate.
Sourcepub fn into_programs(self) -> impl Iterator<Item = Vec<u8>>
pub fn into_programs(self) -> impl Iterator<Item = Vec<u8>>
An owning Iterator over the programs in the predicate.
Sourcepub fn encoded_header(&self) -> Result<EncodedHeader, PredicateError>
pub fn encoded_header(&self) -> Result<EncodedHeader, PredicateError>
Generate the encoding header for this predicate.
Sourcepub fn encode(&self) -> Result<impl Iterator<Item = u8> + '_, PredicateError>
pub fn encode(&self) -> Result<impl Iterator<Item = u8> + '_, PredicateError>
Encode the predicate into a bytes iterator.
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
The size of the encoded predicate in bytes.
This uses usize::saturating_add
to sum the
lengths of the state read and constraint.
This could lead to an incorrect size for a
very large predicate. However, such a predicate
would be invalid due to the size limits.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn decode(bytes: &[u8]) -> Result<Self, DecodeError>
Decode a predicate from bytes.
Sourcepub fn check_predicate_bounds(&self) -> Result<(), PredicateError>
pub fn check_predicate_bounds(&self) -> Result<(), PredicateError>
Check the predicate is within the limits of a valid predicate.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Predicate
impl<'de> Deserialize<'de> for Predicate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Predicate
impl Ord for Predicate
Source§impl PartialOrd for Predicate
impl PartialOrd for Predicate
impl Eq for Predicate
impl StructuralPartialEq for Predicate
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnwindSafe for Predicate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)