Enum etest::ResourceIdImpl
source · 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>>,
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.
source§impl From<String> for ResourceIdImpl<'_>
impl From<String> for ResourceIdImpl<'_>
source§impl<'a> Hash for ResourceIdImpl<'a>
impl<'a> Hash for ResourceIdImpl<'a>
source§impl<'a> PartialEq for ResourceIdImpl<'a>
impl<'a> PartialEq for ResourceIdImpl<'a>
impl<'a> Eq for ResourceIdImpl<'a>
impl<'a> StructuralPartialEq for ResourceIdImpl<'a>
Auto Trait Implementations§
impl<'a> Freeze for ResourceIdImpl<'a>
impl<'a> RefUnwindSafe for ResourceIdImpl<'a>
impl<'a> Send for ResourceIdImpl<'a>
impl<'a> Sync for ResourceIdImpl<'a>
impl<'a> Unpin for ResourceIdImpl<'a>
impl<'a> UnwindSafe for ResourceIdImpl<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)