Trait swipl::term::TermGetable

source ·
pub unsafe trait TermGetable: Sized {
    // Required methods
    fn get(term: &Term<'_>) -> Option<Self>;
    fn name() -> &'static str;
}
Expand description

Trait for getting data from a term reference.

Safety

This is marked unsafe because in order to do term getting, we must be sure that

  • the term is created on the engine which is currently active
  • the given context is a context for this engine

Not checking those preconditions results in undefined behavior. Therefore, care must be taken to ensure that get is actually safe.

The macro [term_getable!] provides a way to safely implement this trait by doing the precondition checks for you.

Required Methods§

source

fn get(term: &Term<'_>) -> Option<Self>

Get data from a term reference.

You’d generally not use this directly, but rather, go through Term::get.

source

fn name() -> &'static str

Get the name of this data type for use in exception reporting.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> TermGetable for bool

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<'a> TermGetable for f64

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<'a> TermGetable for i64

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<'a> TermGetable for u64

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<'a> TermGetable for String

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<'a> TermGetable for Vec<u8>

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<T: ArcBlob> TermGetable for Arc<T>

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

source§

impl<T: TermGetable> TermGetable for Vec<T>

source§

fn get(term: &Term<'_>) -> Option<Self>

source§

fn name() -> &'static str

Implementors§