Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RustでつくるWebアプリケーション(1)
Search
NearMeの技術発表資料です
PRO
December 09, 2022
Programming
57
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RustでつくるWebアプリケーション(1)
NearMeの技術発表資料です
PRO
December 09, 2022
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
PosthogのA/Bテスト機能の紹介
nearme_tech
PRO
0
9
AIフレンドリーなプロダクトに向けて
nearme_tech
PRO
1
32
初めてのLean言語
nearme_tech
PRO
0
63
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
1
19
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
1
56
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
1
65
OpenCode & Local LLM
nearme_tech
PRO
0
180
OpenCode Introduction
nearme_tech
PRO
0
55
【Browser Automation × AI】 Stagehandを試してみよう
nearme_tech
PRO
0
150
Other Decks in Programming
See All in Programming
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
380
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
450
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
JavaDoc 再入門
nagise
1
440
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
190
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
620
A2UI という光を覗いてみる
satohjohn
1
170
Creating Composable Callables in Contemporary C++
rollbear
0
180
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
130
dRuby over BLE
makicamel
2
400
Datadog LLM Observabilityで実現する 安全なLLM Usage 管理
3150
0
130
Oxcを導入して開発体験が向上した話
yug1224
4
370
Featured
See All Featured
Making Projects Easy
brettharned
120
6.7k
New Earth Scene 8
popppiees
3
2.4k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
250
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
210
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
230
Building the Perfect Custom Keyboard
takai
2
810
It's Worth the Effort
3n
188
29k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
360
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Transcript
0 RustでつくるWebアプリケーション(1) 2022-12-9 第24回NearMe技術勉強会 Asahi Kaito
1 今回から、本格的にアプリケーションを 作成していきます
2 今回は、 (1) Actixの使い方 (2) Rustの文法〜trait〜とは ついてまとめます。
3 今回用いるもの • Rust → これがなくては始まらない • Cargo → Rustのプロジェクト作成に必要
• Actix → Rust用のWebフレームワーク
4 Actixとは 公式Webサイトによると... “ Actix Web is a powerful, pragmatic,
and extremely fast web framework for Rust “ 高速なWebフレームワークをRustで作れますよということです! https://actix.rs/
5 Actixの例(基本編) use actix_web::{web, App, HttpRequest, HttpServer, Responder}; async fn
greet(req: HttpRequest) -> impl Responder { let name = req.match_info().get("name").unwrap_or("World"); format!("Hello {}!", &name) } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(greet)) .route("/{name}", web::get().to(greet)) }) .bind(("127.0.0.1", 8080))? .run() .await } https://actix.rs/
6 Actixの例(基本編) use actix_web::{web, App, HttpRequest, HttpServer, Responder}; async fn
greet(req: HttpRequest) -> impl Responder { let name = req.match_info().get("name").unwrap_or("World"); format!("Hello {}!", &name) } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .route("/", web::get().to(greet)) .route("/{name}", web::get().to(greet)) }) .bind(("127.0.0.1", 8080))? .run() .await } https://actix.rs/ “http://127.0.0.1:8080”に接続すると... “http://127.0.0.1:8080/{適当な文字列}”に接続すると...
7 〜ハンズオン中〜
8 Actixの例(getマクロを用いる) use actix_web::{get, web, App, HttpRequest, HttpServer, Responder}; #[get("/")]
async fn index(_req: HttpRequest) -> impl Responder { "Hello from the index page." } async fn hello(path: web::Path<String>) -> impl Responder { format!("Hello {}!", &path) } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(index) .route("/{name}", web::get().to(hello)) }).bind(("127.0.0.1", 8080))?.run().await } https://actix.rs/
9 Actixの例(getマクロを用いる) use actix_web::{get, web, App, HttpRequest, HttpServer, Responder}; #[get("/")]
async fn index(_req: HttpRequest) -> impl Responder { "Hello from the index page." } async fn hello(path: web::Path<String>) -> impl Responder { format!("Hello {}!", &path) } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(index) .route("/{name}", web::get().to(hello)) }).bind(("127.0.0.1", 8080))?.run().await } “http://127.0.0.1:8080”に接続すると... “http://127.0.0.1:8080/{適当な文字列}”に接続すると... https://actix.rs/
10 〜ハンズオン中〜
11 Rustの文法~traitとは?~ • trait = 型 → 複数の構造体などに同じような振る舞いを適用させたいときに 用い る
• traitの使い方 (1) traitを作成する (2) 構造体を作成する (3) implを用いて、traitを構造体に適用する
12 Rustの文法~traitとは?~ (1) traitを作成する pub trait Introduction { fn introduction(&self)
-> String; } (2) 構造体を作成する pub struct Pokemon { pub name: String, pub types: Vec<String>, pub tera_type: String, pub location: String, }
13 Rustの文法~traitとは?~ (3) implを用いて、traitを構造体に適用する impl Introduction for Pokemon { fn
introduction(&self) -> String { format!( "Name: {}, types: {:?}, tera_type: {}, location: {}", self.name, self.types, self.tera_type, self.location ) } }
14 〜ハンズオン中〜
15 Thank you