the new core and its future
Benjamin Kampmann
@gnunicorn:matrix.org
2022-08-27, Matrix Summit Berlin
Freelance Dev since 2011
Rust Dev since 2015 (before Python, JS, etc)
prev. Core Dev @ Parity on Substrate (blockchain dev framework); App-SDK Dev @ MaidSafe
Co-Host RustFest 2016 & 2017
more about me on gnunicorn.org
as fast & sometimes faster than c/c++; no garbage collector
typed; without segfaults; checked at compile time
use rand::Rng;
struct CustomType {
inner: String
}
impl CustomType {
pub fn new(inner: String) -> Self {
CustomType { inner }
}
}
fn main() {
let mut rng = rand::thread_rng();
let num = rng.gen::<u8>();
let conv = match num {
0 => Some(CustomType::new("Zero".to_owned())),
5 => Some(CustomType::new("Zero".to_owned())),
_ => None,
};
if let Some(t) = conv {
println!("{}", t.inner);
} else {
println!("{}", num)
}
}
Matrix Clients are all over the place; developing one is hard and most lack a core aspect end-to-end-encryption because of a lack of well supported libraries. This slows down development of matrix as a whole.
// from `examples/getting_started/src/main.rs:152`
async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
// First, we need to unpack the message: We only want messages from rooms we are
// still in and that are regular text messages - ignoring everything else.
if let Room::Joined(room) = room {
let msg_body = match event.content.msgtype {
MessageType::Text(TextMessageEventContent { body, .. }) => body,
_ => return,
};
// here comes the actual "logic": when the bot see's a `!party` in the message,
// it responds
if msg_body.contains("!party") {
let content = RoomMessageEventContent::text_plain("🎉🎊🥳 let's PARTY!! 🥳🎊🎉");
println!("sending");
// send our message to the room we found the "!party" command in
// the last parameter is an optional transaction id which we don't
// care about.
room.send(content, None).await.unwrap();
println!("message sent");
}
}
}
// ...
Want more vision and future? Join my closing talk today @ 5pm in mainhall