Rust에서 LLVM Intrinsics 호출하기
Posted: November 28, 2015 Filed under: Code, Tokamak Project | Tags: llvm, rust, tokamak Leave a comment요즘에는 내가 보려는 목적으로 기록을 하는 블로깅이 대부분인 듯 하다. Rust는 LLVM으로 구현되어 있고 LLVM 의 Intrinsics를 함수에 매핑해서 호출할 수 있는 기능이 공식적으로 제공된다. 예제는 아래와 같다.
A skeleton code for Iterator in Rust
Posted: October 13, 2015 Filed under: Code | Tags: iterator, rust Leave a commentFor record, I wrote down the same code.
Consuming Iterator
Iterator that does not consume items
Awesome documentation links for Rust
Posted: October 11, 2015 Filed under: Code, FOSS | Tags: rust Leave a commentI wrote down the useful links that I have learned. I’ll continue to update it.
General
- The Rust Programming Language
- Rust for C++ programmers
- The Advanced Rust Programming Language
- Rust for Rubyists
Abstraction
Ownership
- Lifetime in Rust Book
- Understanding Pointers, Ownership, and Lifetimes in Rust
- http://alvalea.gitbooks.io/rust-for-cpp/content/lifetimes.html
- Understanding Lifetime in Rust – Part I
- Understanding Lifetime in Rust – Part II
Object Safety
FFI
- Foreign Function Interface – Rust Book
- C types in Rust
- Rust FFI C string handling
- How do I get a *mut c_char from a Str?
- Rust Once, Run Everywhere
- FFI in Rust – writing bindings for libcpuid
- 24 days of Rust – calling Rust from other languages
- A Pythonist getting Rusty these days… Part 1, Part 2
- Exposing Rust struct to Python
Iterator
- Effectively Using Iterators In Rust
- A Journey into Iterators
- How can I zip more than two iterators?
- Correct way to return an Iterator?
- Itertools (very useful iterator helper utility)
Pattern Matching
Error handling
biild.rs
Examples
Idiomatic Usages of Rust
- Virtual Structs Part 1: Where Rust’s Enum Shines
- Modeling Graphs in Rust Using Vector Indices
- Rust Design Patterns
API Design
- String vs &str in Rust functions
- Creating a Rust function that accepts String or &str
- Creating a Rust function that returns a &str or String
- Learning Rust With Entirely Too Many Linked Lists
- Rust’s Built-in Traits, the When, How & Why
Ownership
Network and I/O
Macro
MIO
- API Documentation
- mio book
- Getting Acquainted with MIO
- mio source code
- Creating A Multi-echo Server using Rust and mio
- Accumulating echo server using Rust’s mio
- My Basic Understanding of mio and Asynchronous IO
Projects Worth Watching
- Awesome Rust
- Rust in Detail
- Asynchronous IO in Rust
- Building an iOS App in Rust, Part 1: Getting Started with Rust
- Creating A Multi-echo Server using Rust and mio
- Index 1,600,000,000 Keys with Automata and Rust
Papers
Profiling
- Blog: Profiling Rust applications (comments)
- Rust Performance: A story featuring perf and flamegraph on Linux
Updates
- Oct 15, 2015 – Added The Little Book of Rust Macros.
- Nov 3. 2015 – Add ‘Rust Design Pattern’ and ‘Exposing Rust struct to Python’
Jni Native를 통한 Rust 함수 호출
Posted: September 25, 2015 Filed under: Code, FOSS, Tokamak Project | Tags: jni, rust, Tajo Leave a comment회사 허락을 맡아 홀로 프로젝트를 하나 시작했다. 큰 그림은 일부 컴포넌트를 Rust로 구현하고 컴포넌트간 연결은 rpc로 하는 것인데 아직 Rust 로 rpc 구현을 하기에 시간이 더 필요하다. 임시적인 수단으로 JNI를 통해 기존 컴포넌트에 연결을 하려고 한다.
그 외 프로젝트에 자세한 이야기는 나중에 설명하고 위 목적으로 Stackoverflow 에서 참고하고 https://github.com/Monnoroch/RustJni 를 참고해서 JNI를 테스트를 해봤다.
C 바인딩이 쉬운것은 Rust의 장점 중 하나인데 JNI 바인딩 역시 순조로웠다. 방법은 우선 아래와 같이 native 함수 인터페이스를 작성하고
아래와 같이 Rust 코드를 작성하면 된다.
이게 전부다. 위에서 사용된 chars_to_str와 str_to_jstring 는 아래 github repository에 있다.
https://github.com/hyunsik/jni-rs/blob/master/src/helper.rs
위 repository 는 https://github.com/Monnoroch/RustJni를 fork 해서 JNI 뿐 아니라 JNI 프로그램 작성 중에 반복되는 코드들에 대한 유틸리티 함수들을 추가할 계획이다.
그리고 아래는 JNI Native + Rust 를 위한 템플릿 프로젝트이다.
https://github.com/hyunsik/rust-jni-template