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
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の技術発表資料です
Claude Code × git worktree で並列開発 (続き) -差分のサービスだけを併設する-
nearme_tech
PRO
1
50
Claude Code × git worktree で並列開発 — サブモジュール構成のリポジトリで成立させる —
nearme_tech
PRO
0
54
LLM + 強化学習
nearme_tech
PRO
0
31
PosthogのA/Bテスト機能の紹介
nearme_tech
PRO
1
45
AIフレンドリーなプロダクトに向けて
nearme_tech
PRO
2
65
初めてのLean言語
nearme_tech
PRO
0
100
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
2
37
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
1
76
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
1
88
Other Decks in Programming
See All in Programming
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
Oxlintはいいぞ(続)
yug1224
1
560
XHTMLが残したもの
yosuke_furukawa
PRO
2
440
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
120
ソフトウェアラスタライザ
fadis
1
790
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
typoなんかねぇよ
raspython3
0
670
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
120
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
210
アクセシビリティから考える情報設計
high_g_engineer
0
300
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
660
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
130
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Embracing the Ebb and Flow
colly
88
5.2k
Rails Girls Zürich Keynote
gr2m
96
14k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
260
Why Our Code Smells
bkeepers
PRO
340
58k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
560
Ethics towards AI in product and experience design
skipperchong
2
360
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Believing is Seeing
oripsolob
1
210
We Have a Design System, Now What?
morganepeng
55
8.3k
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