본문 바로가기

gRPC를 이용해서 Rust와 Flutter를 연동해보자 (2) - 예제 이전 소개 포스트에 이어서 예제를 직접 만들어 보겠습니다. 예제는 gRPC 홈에 있는 quick start의 예제의 proto 파일을 그대로 사용했으며, Rust와 Flutter code는 직접 생성해봤습니다. 다음과 같은 절차로 진행합니다. 준비물 proto file 작성 Rust로 gRPC 공통 library 작성 Rust로 gRPC server 작성 Rust로 gRPC client 작성 Rust Server + Rust Client 연동 테스트 Flutter로 gRPC client 작성 Rust Server + Flutter Client 연동 테스트 마무리하며 1. 준비물 protoc 설치 protoc는 gRPC에서 사용하는 protocol buffer의 compiler다. Windows 환경 ch..
gRPC를 이용해서 Rust와 Flutter를 연동해보자 (1) - 소개 지난 포스트에서는 FFI (Foreign Function Interface)를 활용해서 Rust와 Flutter를 연동했었는데요. 이번에는 HTTP 2.0 기반의 protocol인 gRPC를 활용해서 연동하는 방법에 대해서 알아보고자 합니다. 예제코드를 먼저 보고자 하시는 분들은 다음 포스트로 바로 다음 포스트로 넘어가서 확인하시기 바랍니다. 들어가기 전에 Rust와 Flutter를 연동하는 데 있어서 FFI와 gRPC가 어떤 차이가 있는지 차이점을 아래와 같이 표로 정리해봤습니다. 측면 gRPC FFI (Foreign Function Interface) 통합 복잡성 gRPC는 서비스 간 통신을 위한 프로토콜 중심 접근 방식을 제공하여 통합을 단순화할 수 있습니다. FFI는 낮은 수준의 바인딩과 수동 메..
dart ffi with rust dart ffi(foreign function interface)를 통해 rust library를 사용하는 방법을 공유합니다. 예제 app으로는 rust의 audio library의 하나인 rodio 사용해서 음악을 재생합니다. 본 글의 내용은 https://medium.com/flutter-community/how-to-call-a-rust-function-from-dart-using-ffi-f48f3ea3af2c 에서 영감을 얻어 작성하였고, 2022년 9월 기준으로 빌드 가능한 환경으로 구성했으며, rust library에 대한 내용을 추가했습니다. 준비물 dart SDK v2.18.0 rust v1.63.0 rodio에서 재생가능한 음악 파일 (wav, mp3, ...) windows or mac..
'there is no reactor running, must be called from the context of a Tokio 1.x runtime' async api call을 blocking(synchronous call)으로 처리하고 싶다면(제목의 에러가 발생한다면) 아래와 같은 방법을 사용해서 해결을 할 수가 있다. 다만, async->sync call로 바뀌니 app의 동작에 영향을 줄 수 있다는 점도 참고한다. use tokio::runtime::Runtime; fn main() -> Result { // Create the runtime let rt = Runtime::new()?; // Spawn the root task rt.block_on(async { // your async api call here }); } 소스 출처는 https://docs.rs/tokio/1.11.0/tokio/runtime/index.html tokio::..
Tauri + Svelte + Material UI (+ Dark theme) Prerequisites Windows os (not tested on macos or linux) rust environment https://www.rust-lang.org/tools/install node environment NVM for Windows (recommended) https://github.com/coreybutler/nvm-windows Create tauri app with svelte https://tauri.studio/en/docs/getting-started/intro Run below command yarn create tauri-app And you will see below logs: yarn create v1.22.10 [1/4] Resolving packages...
rust 에서 library, unit test 분리하기 rust에서 library를 분리하고 library code를 테스트하는 unit test를 분리하는 방법을 소개합니다. node.js나 java들과 크게 다르진 않는데, 초반에 셋업할 때 구조를 이해하지 못하면 한참 해맬수가 있어서 공유합니다 아래와 같은 간단한 절차로 진행하면 구조를 이해하는 데 도움이 될 겁니다. 먼저 app를 생성합니다. cargo new my_app app에서 사용한 library를 생성합니다. cd my_app cargo new --lib my_lib library의 unit test 코드를 my_lib/src/lib.rs안에 작성합니다. pub fn add(a: i32, b: i32) -> i32 { a + b } 그리고, 예제로 들어 있던 test code를 my_lib/t..
Lambda with map in Kotlin 아래는 Kotlin에서 lambda function을 map에 넣어서 사용하는 예제 코드입니다. /* * lambda with map */ class MyClass { var myFun = {a: Int, b: Int-> println(a+b) } val map:HashMapUnit> = hashMapOf("myFun" to myFun) fun test() { val c: Int = 3 val d: Int = 5 if (map["myFun"]!=null){ map["myFun"]!!(2,3) } } } fun main() { var c = MyClass() c.test() } 소스코드 실행은 아래의 Kotlin Playground 링크에서 직접 해보세요. https://pl.kotl.in/JaKIvorY6
Learned with Gradle - subprojects property can be shared all subprojects its depedencies, buildscript. - in eclipse, if fails to run gradle, check gradle environment in run configuration, project properties, eclipse preferences