My first Rust Experience

April 18, 2017    rust open-source cargo crates rust-lang

Hi guys.

Two weeks ago I started to learn Rust, for better learning, I decided to rewrite my library mruby-smallhttp on Rust. Let’s get to know Cargo. It’s something like bundler in Ruby world.

$ cargo new library # => generate a template for project
$ tree # =>
├── Cargo.toml
└── src

Cargo.toml it’s a manifest file. If you want to know more about how to get started in Rust, here is the link. it’s a main file for a library. If you create a binary project the main file is

If you want to use my lib in your projects, here is examples:

# Cargo.toml
knock = "0.1"
Simple GET request
extern crate knock;

use knock::HTTP;

fn main() {
	let http = HTTP::new("").unwrap();
	let response = http.get().send();
Simple POST request
extern crate knock;

use knock::HTTP;
use std::collections::HashMap;

fn main() {
    let http = HTTP::new("").unwrap();
    let mut body = HashMap::new();
    let mut headers = HashMap::new();

    body.insert("file", Data::File("/path/to/file.file"));
    body.insert("field", Data::String("value"));

    headers.insert("Content-Type", "multipart/form-data");

    let response =;

After writing knock, I wanted to write a command line tool to send an HTTP request. Before that, I used POSTMAN, but I don’t like electron because it’s Chrome. I don’t like chrome at all, but when it needs to be used to work with POSTMAN it’s too much. So I started using my knock lib for writing command-line tool on Rust.

I wrote it quickly, I had to add some code to knock lib. Now I have a command-line tool with name getsb. It’s not over yet, and now version v0.1.0. I want to add more features. So I will very glad for any help.

How to Install
$ git clone
$ cd getsb-cli
$ cargo build --release

And then move binary file in bin dir:

$ sudo mv target/release/getsb /usr/local/bin
$ sudo mv target/release/getsb /usr/local/bin/getsb
  • Create a folder for getsb
  • search for env
  • open “edit your enviroment variables”
  • edit PATH
  • append folder path to the end of the string ie: <path_stuff_here>;C:/getsb/;
How to use
$ getsb POST -b "key=value" -h "Content-Type: application/x-www-form-urlencoded"

For more info check file.

After all this, I really liked Rust. This is an awesome language with safe working with memory and other awesome things.

If you want to start to learn here is few links:

And also link on my projects:

So, if you want to learn Rust, here is a very nice book.


comments powered by Disqus