Skip to content

Commit

Permalink
fix syntax highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnessOjisan committed Aug 21, 2023
1 parent adbad7c commit b405010
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/contents/20230810-actions-rs-cargo-ari-nashi/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
path: /actions-rs-cargo-ari-nashi
created: "2023-08-10"
title: actions-rs/cargo が非推奨とは言うものの
title: actions-rs/cargo が非推奨とは言うものの
visual: "./visual.png"
tags: [rust, "github-actions"]
userId: sadnessOjisan
Expand Down Expand Up @@ -64,11 +64,11 @@ GitHub Actions では compose できる外部 action は action.yml として定

```yaml
runs:
using: 'node12'
main: 'dist/index.js'
using: "node12"
main: "dist/index.js"
```

とあるので、この処理の本体はそれだ。ただそれはどうみてもビルドした後のコードだ。package.json には
とあるので、この処理の本体はそれだ。ただそれはどうみてもビルドした後のコードだ。package.json には

```
"build": "rm -rf ./dist/* && ncc build src/main.ts --minify"
Expand Down Expand Up @@ -205,7 +205,7 @@ export class RustUp {
で定義されている。install 部分の肝は

```ts
const rustupSh = await tc.downloadTool('https://sh.rustup.rs');
const rustupSh = await tc.downloadTool("https://sh.rustup.rs");
await exec.exec(rustupSh, args);
```

Expand All @@ -219,7 +219,7 @@ await exec.exec(rustupSh, args);

## actions-rs/cargo

```rs
```yaml
- uses: actions-rs/cargo@v1
with:
command: test
Expand Down Expand Up @@ -268,7 +268,7 @@ void main();

`program` は先に見た actins-rs/core だ。

```rs
```rust
public static async get(): Promise<RustUp> {
const exePath = await io.which('rustup', true);
return new RustUp(exePath);
Expand Down
18 changes: 9 additions & 9 deletions src/contents/20230821-why-hyper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Rust でWebサーバーを書く時の技術選定をするときに調べてい

さて、そんな hyper だが公式の example はこのようになっている。

```rs
```rust
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
Expand Down Expand Up @@ -98,7 +98,7 @@ TRPLの例だと、GETを処理するためには HTTP ヘッダーをパース

`GET / HTTP/1.1` という文字列が来たら、

```rs
```rust
let (status_line, filename) = if buffer.starts_with(get) {
("HTTP/1.1 200 OK\r\n\r\n", "hello.html")
} else {
Expand All @@ -112,7 +112,7 @@ let (status_line, filename) = if buffer.starts_with(get) {

それが hyper では

```rs
```rust
async fn echo(
req: Request<hyper::body::Incoming>,
) -> Result<Response<BoxBody<Bytes, hyper::Error>>, hyper::Error> {
Expand Down Expand Up @@ -150,7 +150,7 @@ async fn echo(

それが hyper では

```rs
```rust
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
Expand Down Expand Up @@ -178,7 +178,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {

ちなみに version 0.14 時代は自分で spawn を書く必要はなく、

```rs
```rust
#[tokio::main]
async fn main() {
// We'll bind to 127.0.0.1:3000
Expand Down Expand Up @@ -208,7 +208,7 @@ https://hyper.rs/guides/0.14/server/hello-world/

std 飲みを使うと、リクエストを読み取る、レスポンスを書き込むには用意した buffer の可変参照越しに行う必要があった。

```rs
```rust
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();
```
Expand All @@ -225,7 +225,7 @@ stream.read(&mut buffer).unwrap();

例えば、ルーティングを司る機能を実装し、

```rs
```rust
async fn echo(
req: Request<hyper::body::Incoming>,
) -> Result<Response<BoxBody<Bytes, hyper::Error>>, hyper::Error> {
Expand All @@ -245,7 +245,7 @@ async fn echo(

これを連鎖的に受け取れる middleware の口を用意してあげる。

```rs
```rust
async fn logging_middleware<F>(
req: Request<hyper::body::Incoming>,
handler: F,
Expand All @@ -270,7 +270,7 @@ where

そしてこれらを Service として登録する。

```rs
```rust
tokio::task::spawn(async move {
if let Err(err) = http1::Builder::new()
.serve_connection(
Expand Down

0 comments on commit b405010

Please sign in to comment.