Trait rtest::FromContext

source ·
pub trait FromContext {
    type Context;

    // Required methods
    fn from_context(context: &Self::Context) -> Option<Resource<Self>>
       where Self: Sized;
    fn into_context(context: &Self::Context, res: Resource<Self>)
       where Self: Sized;
    fn get_resource_id() -> ResourceId;
}
Expand description

FromContext must be defined for all resources to be used within tests. rather than doing this manually, you can use the derive macro

use rtest_derive::FromContext;

#[derive(FromContext)]
struct FileInfo {
    name: String,
}

Required Associated Types§

Required Methods§

source

fn from_context(context: &Self::Context) -> Option<Resource<Self>>
where Self: Sized,

Extracts a Resource from Context and uses it

source

fn into_context(context: &Self::Context, res: Resource<Self>)
where Self: Sized,

Injects a Resource back into Context for further use

source

fn get_resource_id() -> ResourceId

used to communicate which resources are missing

Object Safety§

This trait is not object safe.

Implementors§