macro_rules! new_default_environment {
($env_name:ident, desktop
$(, with=($display:expr, $queue:expr))?
$(,fields = [$($fname:ident : $fval:expr),* $(,)?])?
$(,)?
) => { ... };
($env_name:ident, with=($display:expr, $queue:expr)
$(,fields = [$($fname:ident : $fval:expr),* $(,)?])?
$(,)?
) => { ... };
($env_name:ident
$(,fields = [$($fname:ident : $fval:expr),* $(,)?])?
$(,)?
) => { ... };
}
Expand description
Initialize a batteries-included SCTK environment
Sister macro of default_environment!
. You need
to use it to initialize the environment instead of
Envrionment::init
. It has the same semantics.
If a preset was used for default_environment!
, it
must be provided here as well.
The macro will automatically setup a Wayland connection and evaluate to a Result
containing either Ok((env, display, queue))
, providing you the initialized Environment
as well as the wayland Display
and EventQueue
associated to it, or to an error
if the connection failed.
let (env, display, queue) = new_default_environment!(MyEnv,
desktop, // the optional preset
/* initializers for your extra fields if any, can be ommited if no fields are added */
fields=[
somefield: 42,
otherfield: String::from("Hello World"),
]
).expect("Unable to connect to the wayland compositor");
If you instead want the macro to use some pre-existing display and event queue, you can
add the with
argument providing them. In that case the macro will evaluate to
a Result<Environment, io::Error>
, forwarding to you any error that may have occured
during the initial roundtrips.
let env = new_default_environment!(MyEnv,
desktop, // the optional preset
with=(display, queue), // the display and event queue to use
/* initializers for your extra fields if any, can be ommited if no fields are added */
fields=[
somefield: 42,
otherfield: String::from("Hello World"),
]
).expect("Initial roundtrips failed!");