Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RustでつくるWebアプリケーション(1)
Search
NearMeの技術発表資料です
PRO
December 09, 2022
Programming
65
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の技術発表資料です
AIエージェントのための 隔離された安全なインフラ設計
nearme_tech
PRO
0
22
Claude Code × git worktree で並列開発 (続き) -差分のサービスだけを併設する-
nearme_tech
PRO
1
69
Claude Code × git worktree で並列開発 — サブモジュール構成のリポジトリで成立させる —
nearme_tech
PRO
0
79
LLM + 強化学習
nearme_tech
PRO
0
37
PosthogのA/Bテスト機能の紹介
nearme_tech
PRO
1
110
AIフレンドリーなプロダクトに向けて
nearme_tech
PRO
2
70
初めてのLean言語
nearme_tech
PRO
0
110
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
2
50
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
1
93
Other Decks in Programming
See All in Programming
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
300
気持ちぃ〜角丸 Squircle
ryu1013
0
310
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
190
AWSに止められる覚悟してますか?
morizo_1984
2
530
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
The Rails Doctrine Decade
koic
2
590
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
410
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
Featured
See All Featured
Music & Morning Musume
bryan
48
7.4k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Product Roadmaps are Hard
iamctodd
55
13k
Evolving SEO for Evolving Search Engines
ryanjones
0
330
Marketing to machines
jonoalderson
1
5.9k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
GitHub's CSS Performance
jonrohan
1033
470k
How to Ace a Technical Interview
jacobian
280
24k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
For a Future-Friendly Web
brad_frost
184
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
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