Hello ELement-Call!

Now that you’ve installed the needed building blocks, let’s adapt the Frontend.
Writing and Running the ELement-Call frontend
First, we make a new project using Cargo. With its .toml file we allow Rust to declare the various dependencies and metadata. That ensures that you’ll always get a repeatable output of the build.
Go ahead like so:
$ cargo new element-call
$ cd element-call
The first command, cargo new, takes the name of the project
(“element-call”) as the first argument. The second command changes to
the new project’s directory.
Look at the generated Cargo.toml file:
Filename: Cargo.toml
[package]
name = "element_call_hello_example"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
Listing 1-1: Default metadata “element_call_hello”
With cargo new, a default project structure is created. Maybe the
author information is already exchanged if Cargo could obtain a definition
from your environment. Cargo also generated source code for a “Hello, world!”
program. Let’s Check out the corresponding src/main.rs file:
Filename: src/main.rs
fn main() { println!("Hello, world!"); }
Listing 1-2: Default source file “main.rs”
No need to compile that stage with cargo run, since we are going to
exchange the project metadata, as well as the element-call source code right
away.
Update Cargo.toml
First reopen the Cargo.toml file and enter the Code in Listing 1-1 into Cargo.toml
Filename: Cargo.toml
[package]
name = "element_call_hello"
version = "0.0.1"
authors = [
"Ralf Zerres <ralf.zerres.de@gmail.com>",
]
description = "The Element-Call - Training project"
documentation = "https://docs.rs/orbtk"
repository = "https://github.com/redox-os/orbtk"
readme = "README.md"
license = "MIT"
keywords = [
"element-call",
"matrix",
"matrixrtc",
]
edition = "2021"
[profile.dev]
opt-level = 1
[dependencies]
#element-call = { git = "https://gitea.networkx.de/rzerres/element-call-book.git", branch = "develop" }
[[bin]]
name = "element_call_hello"
path = "src/main.rs"
Listing 1-1: Project metadata “Element-Call”
You may wonder, why the name property inside the Cargo.toml is
formatted like element_call.
name = "element_call_hello"
It is a good habit to follow rusts
naming convention, that encourages you to use snake_case
naming. While expanding the Element-Call example sources, we will keep
the grouping prefix element-call. That way we end up to call our first target
binary element-call_hello.
Update main.rs
All of the Element-Call specific code that is needed to build our first example “Hello Element-Call!” is shown in Listing 1-2. It goes to src/main.rs.
Filename: src/main.rs
use element-call::prelude::*;
fn main() {
element-call::initialize();
.run();
}
Listing 1-2: Code that creates a Window and prints “Hey Element-Call!”
Save the file and go back to your terminal window. Enter the following commands to compile and run the file:
$ cargo run --release element_call_hello
Compiling and Running Are Separate Steps
Before running an Element-Call application, you must compile its source code. A typical Element-Call project will generate the executable binary code using cargo and place the result in the target subfolder of the project.
Profiles may be used to configure compiler options such as optimization levels
and debug settings. By default the dev or test profiles are used. If the
--release flag is given, then the release or bench profiles are used.
$ cargo build --release --bin element-call-hello.rs
$ ../target/release/hello_element_call
On Windows, you need to use backslash as a path delimiter:
> cargo build --release --bin element-call-hello.rs
> ..\target\release\element_call_hello.exe
If you like to get debug feedback you can call the build process like this
$ cargo build --features debug --bin element-call-hello.rs