Passdata

Struct Passdata 

Source
pub struct Passdata<'s> { /* private fields */ }
Expand description

Data for the logic program.

Implementations§

Source§

impl<'s> Passdata<'s>

Source

pub const unsafe fn new_unchecked(schema: &'s Schema<'s>, data: Vec<u8>) -> Self

Constructs with empty data.

§Safety

The data is not verified to be valid.

Source

pub const fn with_schema(schema: &'s Schema<'s>) -> Self

Constructs with the given schema and empty data.

Source

pub fn into_inner(self) -> Vec<u8>

Returns the underlying encoded data.

Source

pub fn predicates_iter(&self) -> impl Iterator<Item = &str> + '_

Iterator over predicates.

Source

pub fn edb_iter( &self, predicate: &str, ) -> Result<impl Iterator<Item = FactTerms<'_>> + '_>

Iterator over facts.

§Errors
  • if the predicate is unknown.
Source

pub fn add_fact<'a, T>(&mut self, predicate: &str, constants: T) -> Result<()>
where T: IntoArray<Constant<'a>>, <T as IntoArray<Constant<'a>>>::Length: ArrayLength<ConstantTy> + ArrayLength<ConstantId>,

Add a fact explicitly.

§Errors

Returns an error if the values do not match the expected types for the predicate.

Source

pub fn query_edb<'a, T>( &'a self, predicate: &str, values: T, ) -> Result<impl Iterator<Item = T::ResultTy> + 'a>
where T: QueryResult<'a> + 'a,

Query for an explictly declared fact.

§Errors

If the expected types are not compatible with the types in the data.

Source

pub fn contains_edb<'a, T>(&'a self, pred: &str, values: T) -> Result<bool>
where T: QueryResult<'a> + 'a,

Determines if there is any explicitly declared fact which matches the given parameters.

§Errors

If the expected types are not compatible with the types in the data.

Source

pub fn query_only_one_edb<'a, T>( &'a self, pred: &str, values: T, ) -> Result<Option<T::ResultTy>>
where T: QueryResult<'a> + 'a,

Queries the data for an explicitly declared fact, and only returns a success if there is a single matching fact.

§Errors
  • If the expected types are not compatible with the types in the data.
  • If there are multiple matching facts

Trait Implementations§

Source§

impl<'s> Debug for Passdata<'s>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> Freeze for Passdata<'s>

§

impl<'s> RefUnwindSafe for Passdata<'s>

§

impl<'s> Send for Passdata<'s>

§

impl<'s> Sync for Passdata<'s>

§

impl<'s> Unpin for Passdata<'s>

§

impl<'s> UnwindSafe for Passdata<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.