rcore::context
This commit is contained in:
parent
8997900157
commit
f4a3220548
21
src/rcore.rs
21
src/rcore.rs
@ -3,6 +3,7 @@
|
||||
//! Allows for more generic behaviour via [`Context`], as opposed to original async-only.
|
||||
|
||||
mod addresses;
|
||||
mod context;
|
||||
mod diagnostic;
|
||||
mod hashing;
|
||||
mod origin;
|
||||
@ -18,6 +19,7 @@ use std::{error::Error, rc::Rc};
|
||||
use crate::func::*;
|
||||
|
||||
pub use self::addresses::Addresses;
|
||||
pub use self::context::Context;
|
||||
pub use self::diagnostic::Diagnostic;
|
||||
pub use self::hashing::{Hash, HASH_SIZE, HASH_ZEROS};
|
||||
pub use self::origin::{OFctr, Origin};
|
||||
@ -30,25 +32,6 @@ pub use self::resolution::{
|
||||
pub use self::serialization::{Deserializer, DeserializerExt, Serializable, Serializer};
|
||||
pub use self::slice_deserializer::SliceDeserializer;
|
||||
|
||||
/// Execution context.
|
||||
pub trait Context<'a>: 'a {
|
||||
/// Type to provide for [Monad]ic representation of computation, mostly that of resolution ([`Resolution`]).
|
||||
type T: Monad<'a>;
|
||||
|
||||
/// Type to allow improved support for result evaluation.
|
||||
/// This is important for async applications stopping early.
|
||||
type Fallible: MonadFailAny<'a, T = Self::T>;
|
||||
|
||||
/// See [`Diagnostic`].
|
||||
type D: Diagnostic<'a, Self::T>;
|
||||
|
||||
/// Type to represent resolution errors mainly arising in [`Resolver::resolve`].
|
||||
type LookupError: 'a + Error;
|
||||
|
||||
/// Get [type@Hash] of a slice, mostly for use in [`Point`].
|
||||
fn hash(s: &[u8]) -> Hash;
|
||||
}
|
||||
|
||||
/// Helper alias for [`WeakFunctor::F`] of [`Context::T`].
|
||||
pub type Wrapped<'a, Ctx, A> = Wrap<'a, A, <Ctx as Context<'a>>::T>;
|
||||
|
||||
|
20
src/rcore/context.rs
Normal file
20
src/rcore/context.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use super::*;
|
||||
|
||||
/// Execution context.
|
||||
pub trait Context<'a>: 'a {
|
||||
/// Type to provide for [Monad]ic representation of computation, mostly that of resolution ([`Resolution`]).
|
||||
type T: Monad<'a>;
|
||||
|
||||
/// Type to allow improved support for result evaluation.
|
||||
/// This is important for async applications stopping early.
|
||||
type Fallible: MonadFailAny<'a, T = Self::T>;
|
||||
|
||||
/// See [`Diagnostic`].
|
||||
type D: Diagnostic<'a, Self::T>;
|
||||
|
||||
/// Type to represent resolution errors mainly arising in [`Resolver::resolve`].
|
||||
type LookupError: 'a + Error;
|
||||
|
||||
/// Get [type@Hash] of a slice, mostly for use in [`Point`].
|
||||
fn hash(s: &[u8]) -> Hash;
|
||||
}
|
Loading…
Reference in New Issue
Block a user