pub enum ResourceIdImpl<'a> {
Id(Cow<'a, str>),
None,
Basic,
}Expand description
A resource which can be “used” or “consumed”
To be used with the uses and consumes parameters of #[etest]. For type
safety custom types can be specified which implement Into<ResourceId>.
E.g.
enum Output {
Auto,
Hdmi,
Lvds,
}
impl From<Output> for ResourceId
{
fn from(o: Output) -> Self {
let o = match o {
// this is evaluated at runtime of the test
Output::Auto if is_hdmi_connected() => Output::Hdmi,
Output::Auto => Output::Lvds,
o => o,
};
match o {
Output::Hdmi => "hdmi".into(),
Output::Lvds => "lvds".into(),
Output::Auto => unreachable!(),
}
}
}
#[etest(consumes=[Output])]
fn test() {}Variants§
Id(Cow<'a, str>)
Normal resource
None
An empty resource which will be ignored.
Used e.g. when generating a list of resources dynamically where some of the resources are optional and can be omitted.
Basic
Basic resource which is used by all tests.
Unless specified else (by the no_default_uses attribute), this
resource will be implicitly added to the “uses” list of every test.
To avoid parallel execution with other ones, a test can add this
resource type to its “consumes” list by the notparallel attribute.
Implementations§
Trait Implementations§
Source§impl<'a> Clone for ResourceIdImpl<'a>
impl<'a> Clone for ResourceIdImpl<'a>
Source§fn clone(&self) -> ResourceIdImpl<'a>
fn clone(&self) -> ResourceIdImpl<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for ResourceIdImpl<'a>
impl<'a> Debug for ResourceIdImpl<'a>
Source§impl<'a> From<&'a str> for ResourceIdImpl<'a>
impl<'a> From<&'a str> for ResourceIdImpl<'a>
Source§impl<'a, T> From<Option<T>> for ResourceIdImpl<'a>where
T: Into<ResourceIdImpl<'a>>,
Maps an option to a ResourceId.
impl<'a, T> From<Option<T>> for ResourceIdImpl<'a>where
T: Into<ResourceIdImpl<'a>>,
Maps an option to a ResourceId.
Value of None maps to the special ResourceId::None resource type
which will be ignored when building list of resources dynamically.