Skip to content

Commit dcc0cea

Browse files
authored
[rust/vidi] viz has been renamed to vidi (#10369)
1 parent 865587a commit dcc0cea

30 files changed

+174
-821
lines changed
File renamed without changes.

frameworks/Rust/vidi/Cargo.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[package]
2+
name = "vidi"
3+
version = "0.1.0"
4+
edition = "2024"
5+
publish = false
6+
authors = ["Fangdun Tsai <[email protected]>"]
7+
8+
[[bin]]
9+
name = "vidi"
10+
path = "src/main.rs"
11+
12+
[[bin]]
13+
name = "vidi-pg"
14+
path = "src/main_pg.rs"
15+
required-features = ["tokio-postgres", "yarte"]
16+
17+
[dependencies]
18+
vidi = "0.1"
19+
hyper = "1.0"
20+
hyper-util = "0.1"
21+
http-body-util = "0.1"
22+
atoi = "2.0"
23+
serde = { version = "1.0", features = ["derive"] }
24+
serde_json = "1"
25+
mime = "0.3"
26+
rand = { version = "0.9", features = ["small_rng"] }
27+
thiserror = "2.0"
28+
futures-util = "0.3"
29+
socket2 = { version = "0.6.0", features = ["all"] }
30+
num_cpus = "1.0"
31+
32+
[target.'cfg(not(unix))'.dependencies]
33+
nanorand = { version = "0.8" }
34+
35+
[target.'cfg(unix)'.dependencies]
36+
nanorand = { version = "0.8", features = ["getrandom"] }
37+
38+
tokio = { version = "1", features = ["full"] }
39+
tokio-postgres = { version = "0.7", optional = true }
40+
41+
yarte = { version = "0.15", features = ["bytes-buf", "json"], optional = true }
42+
43+
[profile.release]
44+
lto = true
45+
codegen-units = 1
46+
strip = true
47+
opt-level = 3
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# [viz](https://github.com/viz-rs) web framework
1+
# [vidi] web framework
22

33
## Description
44

55
Fast, robust, flexible, lightweight web framework for Rust.
6+
7+
[vidi]: https://github.com/viz-rs/vidi
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"framework": "vidi",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Platform",
11+
"database": "none",
12+
"framework": "Vidi",
13+
"language": "Rust",
14+
"flavor": "None",
15+
"orm": "Raw",
16+
"platform": "Rust",
17+
"webserver": "Hyper",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "Vidi",
21+
"notes": "",
22+
"versus": "None"
23+
},
24+
"pg": {
25+
"db_url": "/db",
26+
"fortune_url": "/fortunes",
27+
"query_url": "/queries?q=",
28+
"update_url": "/updates?q=",
29+
"port": 8080,
30+
"approach": "Realistic",
31+
"classification": "Fullstack",
32+
"database": "postgres",
33+
"framework": "Vidi",
34+
"language": "Rust",
35+
"flavor": "None",
36+
"orm": "Raw",
37+
"platform": "Rust",
38+
"webserver": "Hyper",
39+
"os": "Linux",
40+
"database_os": "Linux",
41+
"display_name": "Vidi [Postgresql]",
42+
"notes": "",
43+
"versus": "None"
44+
}
45+
}
46+
]
47+
}

frameworks/Rust/vidi/config.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[framework]
2+
name = "vidi"
3+
4+
[main]
5+
urls.plaintext = "/plaintext"
6+
urls.json = "/json"
7+
approach = "Realistic"
8+
classification = "Micro"
9+
database = "Postgres"
10+
database_os = "Linux"
11+
os = "Linux"
12+
orm = "Raw"
13+
platform = "None"
14+
webserver = "vidi"
15+
versus = ""
16+
17+
[pg]
18+
urls.db = "/db"
19+
urls.query = "/queries?q="
20+
urls.update = "/updates?q="
21+
urls.fortune = "/fortunes"
22+
approach = "Realistic"
23+
classification = "Fullstack"
24+
database = "Postgres"
25+
database_os = "Linux"
26+
os = "Linux"
27+
orm = "Raw"
28+
platform = "None"
29+
webserver = "vidi"
30+
versus = ""
File renamed without changes.

frameworks/Rust/viz/src/db_pg.rs renamed to frameworks/Rust/vidi/src/db_pg.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::{collections::HashMap, fmt::Write, io, sync::Arc};
22

3-
use futures_util::{stream::FuturesUnordered, StreamExt, TryFutureExt, TryStreamExt};
4-
use rand::{rng, rngs::SmallRng, Rng, SeedableRng};
3+
use futures_util::{StreamExt, TryFutureExt, TryStreamExt, stream::FuturesUnordered};
4+
use rand::{Rng, SeedableRng, rng, rngs::SmallRng};
55
use tokio::pin;
6-
use tokio_postgres::{connect, types::ToSql, Client, NoTls, Statement};
7-
use viz::{Error, IntoResponse, Response, StatusCode};
6+
use tokio_postgres::{Client, NoTls, Statement, connect, types::ToSql};
7+
use vidi::{Error, IntoResponse, Response, StatusCode};
88

99
use crate::models::{Fortune, World};
1010

@@ -21,7 +21,7 @@ pub enum PgError {
2121

2222
impl From<PgError> for Error {
2323
fn from(e: PgError) -> Self {
24-
Error::Responder(e.into_response())
24+
Error::Responder(Box::new(e.into_response()))
2525
}
2626
}
2727

frameworks/Rust/viz/src/main.rs renamed to frameworks/Rust/vidi/src/main.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(clippy::unused_async)]
22

33
use serde::Serialize;
4-
use viz::{
5-
header::{HeaderValue, CONTENT_TYPE, SERVER},
4+
use vidi::{
65
Bytes, Request, Response, ResponseExt, Result, Router,
6+
header::{CONTENT_TYPE, HeaderValue},
77
};
88

99
mod server;
@@ -14,12 +14,11 @@ struct Message {
1414
message: &'static str,
1515
}
1616

17+
const HELLO_WORLD: &str = "Hello, World!";
18+
1719
#[inline(always)]
1820
async fn plaintext(_: Request) -> Result<Response> {
19-
let mut res = Response::text("Hello, World!");
20-
res.headers_mut()
21-
.insert(SERVER, HeaderValue::from_static("Viz"));
22-
Ok(res)
21+
Ok(Response::text(HELLO_WORLD))
2322
}
2423

2524
#[inline(always)]
@@ -28,15 +27,14 @@ async fn json(_: Request) -> Result<Response> {
2827
.body(
2928
http_body_util::Full::new(Bytes::from(
3029
serde_json::to_vec(&Message {
31-
message: "Hello, World!",
30+
message: HELLO_WORLD,
3231
})
3332
.unwrap(),
3433
))
3534
.into(),
3635
)
3736
.unwrap();
3837
let headers = res.headers_mut();
39-
headers.insert(SERVER, HeaderValue::from_static("Viz"));
4038
headers.insert(
4139
CONTENT_TYPE,
4240
HeaderValue::from_static(mime::APPLICATION_JSON.as_ref()),

frameworks/Rust/viz/src/main_pg.rs renamed to frameworks/Rust/vidi/src/main_pg.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
use std::sync::Arc;
22

3-
use viz::{
4-
header::{HeaderValue, SERVER},
5-
types::State,
6-
Request, RequestExt, Response, ResponseExt, Result, Router,
7-
};
3+
use vidi::{Request, RequestExt, Response, ResponseExt, Result, Router, types::State};
84
use yarte::Template;
95

106
mod db_pg;
117
mod models;
128
mod server;
139
mod utils;
1410

15-
use db_pg::{get_conn, PgConnection};
11+
use db_pg::{PgConnection, get_conn};
1612

1713
#[derive(Template)]
1814
#[template(path = "fortune.hbs")]
@@ -28,9 +24,8 @@ async fn db(req: Request) -> Result<Response> {
2824

2925
let world = conn.get_world().await?;
3026

31-
let mut res = Response::json(world)?;
32-
res.headers_mut()
33-
.insert(SERVER, HeaderValue::from_static("Viz"));
27+
let res = Response::json(world)?;
28+
3429
Ok(res)
3530
}
3631

@@ -43,10 +38,7 @@ async fn fortunes(req: Request) -> Result<Response> {
4338
.call()
4439
.expect("error rendering template");
4540

46-
let mut res = Response::html(buf);
47-
res.headers_mut()
48-
.insert(SERVER, HeaderValue::from_static("Viz"));
49-
Ok(res)
41+
Ok(Response::html(buf))
5042
}
5143

5244
async fn queries(req: Request) -> Result<Response> {
@@ -55,9 +47,8 @@ async fn queries(req: Request) -> Result<Response> {
5547

5648
let worlds = conn.get_worlds(count).await?;
5749

58-
let mut res = Response::json(worlds)?;
59-
res.headers_mut()
60-
.insert(SERVER, HeaderValue::from_static("Viz"));
50+
let res = Response::json(worlds)?;
51+
6152
Ok(res)
6253
}
6354

@@ -67,9 +58,8 @@ async fn updates(req: Request) -> Result<Response> {
6758

6859
let worlds = conn.update(count).await?;
6960

70-
let mut res = Response::json(worlds)?;
71-
res.headers_mut()
72-
.insert(SERVER, HeaderValue::from_static("Viz"));
61+
let res = Response::json(worlds)?;
62+
7363
Ok(res)
7464
}
7565

File renamed without changes.

0 commit comments

Comments
 (0)