More content and improve formatting

This commit is contained in:
finga 2020-12-21 15:11:43 +01:00
parent 0d8c15d2e3
commit 652c821c3b

View file

@ -42,7 +42,7 @@
- Performance of idiomatic Rust is comparable to the performance
of idiomatic cpp
** Where to get infos
** Where to get further information?
*** Docs...
- [[https://doc.rust-lang.org/book/][The rust book]] (~$ rustup docs --book~), [[https://doc.rust-lang.org/rust-by-example/][Rust by example]]
@ -57,16 +57,24 @@
** What are we going to use?
*** Definitely
- [[https://rocket.rs][rocket]]
- [[https://diesel.rs][diesel]]
- log
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- [[https://rocket.rs][rocket]]
- [[https://diesel.rs][diesel]]
- log
*** Maybe
- anyhow
- lettre
- sha3
- serde
- chrono
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- anyhow
- lettre
- sha3
- serde
- chrono
** How to install
@ -119,25 +127,124 @@
- Testing (Unit tests)
- Typed URIs
** Where to get infos?
** Where to get further information?
*** Docs...
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- [[https://rocket.rs][rocket.rs]]
- [[https://rocket.rs/v0.4/guide/][Rocket Guide]]
- [[https://api.rocket.rs/v0.4/rocket/][Rocket API docs]]
- [[https://github.com/SergioBenitez/Rocket/tree/v0.4/examples][Examples]]
*** Chat
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- Matrix: [[https://chat.mozilla.org/#/room/%23rocket:mozilla.org][#rocket:mozilla.org]]
- IRC on Freenode: [[https://kiwiirc.com/client/chat.freenode.net/#rocket][#rocket]]
* Diesel
** What is an ORM?
Object-relational-mapping is a programming technique for converting
data between incompatible type systems using the paradigms of your
programming language.
** What is diesel capable of?
*** Pros
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- Models are DRY (don't repeat yourself)
- Cleaner separation
- Prepared and sanitised queries
- Changes are versioned
*** Cons
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- Debugging can get more complicated (performance)
- No need to learn SQL
** Prerequisites ~diesel_cli~
*** Setup Diesel for default DBMS
#+BEGIN_SRC sh
$ sudo apt install libpq-dev libsqlite3-dev \
default-libmysqlclient-dev
$ cargo install diesel_cli
#+END_SRC
*** Setup Diesel for SQLite only
#+BEGIN_SRC sh
$ sudo apt install libsqlite3-dev
$ cargo install diesel_cli -no-default-features \
--features sqlite
#+END_SRC
** How does that look in Rust
*** Define a struct
:PROPERTIES:
:BEAMER_col: 0.50
:BEAMER_env: block
:END:
#+BEGIN_SRC rust
#[derive(Queryable)]
pub struct NewComment<'a> {
name: &'a str,
email: &'a str,
comment: &'a str,
}
#+END_SRC
*** Insert something
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
#+BEGIN_SRC rust
let user = NewUser {
name: "foo",
email: "foo@bar.baz",
comment: "A comment",
};
insert_into(comments)
.values(&user)
.execute(conn);
#+END_SRC
** Where to get further information?
*** Docs...
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- [[https://diesel.rs][diesel.rs]]
- [[https://diesel.rs/guides/][Diesel Guides]]
- [[https://docs.diesel.rs/master/diesel/index.html][Diesel API docs]]
- [[https://github.com/diesel-rs/diesel/tree/master/examples][Examples]] (minimalistic)
*** Support
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- [[https://gitter.im/diesel-rs/diesel][Gitter]]
- [[https://discourse.diesel.rs/][Discourse Forum]]
* Lets code something
** Lets create a small web app
* Conclusion
** What did we do?
@ -147,12 +254,20 @@
** Two small projects
*** [[https://git.onders.org/finga/ldap0r][ldap0r]]
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- LDAP password reset tool
- ($\sim$ 300 SloC)
- First release
- Tests
*** [[https://git.onders.org/finga/filerly][filerly]]
:PROPERTIES:
:BEAMER_col: 0.45
:BEAMER_env: block
:END:
- File sharing a la NextCloud
- Not ready yet, work in progress...