Rust
-
Rust: actix-rs에서 HTML tera 엔진 렌더링컴퓨터/Rust 2022. 6. 24. 11:24
actix-rs Actix Web | A powerful, pragmatic, and extremely fast web framework for Rust. Request Routing The built-in Actix Web request router can be used with or without macros attached to handlers, and always provides flexible and composable methods of creating routing tables. Includes support for matching dynamic path segments, path prefix actix.rs 소개 이 글에선 Python django 처럼 HTML 엔진을 이용해서 코드를 HT..
-
Rust: Cross compile for Raspberry PI컴퓨터/Rust 2022. 6. 24. 10:24
라즈베리파이에서 러스트를 빌드하는 데는 굉장히 오래 걸릴 수가 있다. 그래서 호스트 OS 환경 (ex 윈도우)에서 라즈베리 파이용 크로스 컴파일하는 법이다. 우선, WSL 설치가 필요하다. 셋업 우선 타겟 버전 Rust 라이브러리를 받아야 한다. (GNU 컴파일러와 같이 링커 CC 설치했다고 가정) rustup target add armv7-unknown-linux-gnueabihf 프로젝트 최상위 폴더에 .cargo 를 만들고 안에 config.toml 파일을 만든다. 파일 안에 다음과 같이 추가한다. (파이 2/3/4 용) .cargo/config.toml [build] # Pi 2/3/4 [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnu..
-
Rust fleet (cargo 대체 빌드 툴)컴퓨터/Rust 2022. 5. 4. 22:36
fleet.rs GitHub - dimensionhq/fleet: 🚀 The blazing fast build tool for Rust. 🚀 The blazing fast build tool for Rust. Contribute to dimensionhq/fleet development by creating an account on GitHub. github.com 소개 기본 cargo와 비교했을 때 5배까지 빠를 수 있다는 fleet 빌드 툴 nigtly에서만 사용 가능하며 Rust ecosystem에 있는 (sccache, lld, zld, ramdisks 등을 이용해) 기본 툴들을 최적화함 외부 라이브러리 의존도가 높으면 그렇게 차이는 없는 듯 설치법 cargo install --git https:..
-
Rust: chrono, timezone 예제컴퓨터/Rust 2021. 9. 8. 19:55
chrono GitHub - chronotope/chrono: Date and time library for Rust Date and time library for Rust. Contribute to chronotope/chrono development by creating an account on GitHub. github.com 예제 이 crate는 rust에서 date를 쉽게 이용할 수 있게 도와준다. timezone을 쓰기 위해서 파이썬에서처럼 별도의 라이브러리가 필요하다. chrono_tz GitHub - chronotope/chrono-tz: TimeZone implementations for rust-chrono from the IANA database TimeZone implementati..
-
Rust: Cross compile to linux on windows컴퓨터/Rust 2021. 8. 30. 13:00
Rust Rust Programming Language A language empowering everyone to build reliable and efficient software. www.rust-lang.org Rust 크로스 컴파일 윈도우 10에서 AWS EC2에서 사용할 바이너리를 빌드할 것이다. (x86_64-unknown-linux) 1. 타겟 추가 rustup target add x86_64-unknown-linux 2. WSL 2 실행 bash 3. cargo config 프로젝트에서 bash를 해서 build 하면 권한 문제가 발생할 수 있다. 프로젝트 최상위에 .cargo 폴더를 만들고 config 파일을 만들어서 아래처럼 수정한다. (.cargo/config) (env를 .bash..
-
Rust: actix + MongoDB컴퓨터/Rust 2021. 8. 28. 09:59
actix std::io::Result { // MongoDB Client let client_options = ClientOptions::parse(project::MONGO_URL).await.unwrap(); let client = web::Data::new(Mutex::new(Client::with_options(client_options).unwrap())); // start http server HttpServer::new(move || { App::new() .app_data(client.clone()) // store db pool in app state .wrap(middleware::Logger::default()) .service(project::hello::hello) }) .bin..
-
Rust: reqwest GET/POST snippet컴퓨터/Rust 2021. 8. 19. 15:47
[dependencies] reqwest = { version = "0.11", features = ["json", "blocking"] } ... GET use reqwest::header::USER_AGENT; pub async fn get() -> Result { let client = reqwest::Client::builder() .danger_accept_invalid_certs(true) .build()?; // USER_AGENT 설정 let res = client.get(URL).header(USER_AGENT, "User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome..
-
Rust: actix를 이용하여 카카오 챗봇 만들기컴퓨터/Rust 2021. 8. 2. 16:06
결과물 백엔드 + 프론트엔드 + 카카오톡 챗봇 프로젝트 Rust 언어 github.com Go언어 gin으로 만들기: @참고 Python언어 FastAPI로 만들기: @참고 Python, Go, C, Rust 언어로 카카오 챗봇을 만들어 보았는데 Go랑 Rust로 만드는 걸 추천드립니다. 1. 카카오 챗봇 만들기 준비물 카카오 i 챗봇 사용 허락 @링크 AWS EC2나 구름 IDE 환경 준비하기 @AWS EC2 만들기 링크 AWS RDS (MySQL), AWS S3 위 준비를 다했으면 학교 일정을 MySQL에 저장해서, 사용자가 "달력", "일정"... 이란 발화 문을 제시하면 MySQL에서 일정을 불러와서 보여줄 것이다. 2. 시나리오 만들기 발화 문 지정 엔티티를 만들어서, "일정", "달력"과 같은..