Download a single file from a Git repository.

Overview

git-download

Crates.io documentation CI

Microservices architecture requires sharing service definition files like in protocol buffer, for clients to access the server.

To share the files, one can choose primitive copy & paste approach but this is too vulnerable to human mistakes.

The second and now widely accepted approach is protodep however, this isn't the best solution for Rust programmers

Because we, Rust programmers, want to download the files just like this in build.rs.

// build.rs

git_download::repo("https://github.com/akiradeveloper/lol")
    .branch_name("v0.9.1")
    .add_file("lol-core/proto/lol-core.proto", "proto/lol.proto")
    .exec()?;

tonic_build::configure()
    .build_server(false)
    .compile(&["lol.proto"], &["proto"])?;

Usage

[build-dependencies]
git-download = "0.1"

Implementation

Internally, git-download uses sparse-checkout to download designated files not the entire repository.

The downloaded files are firstly put in temporary directory which is created by tempfile crate. In Linux, the directory is created in tmpfs which is an in-memory filesystem. Therefore, no disk write occurs before copying the file in the tmpfs to the destination path. We can avoid writing the unchanged content by comparing the content before copying.

You might also like...
An mdBook single PDF generator using pure Rust and some Node.js

mdbook-compress An mdBook backend renderer to generate a single PDF file for a full book. There are other similar projects, but most rely on chrome in

Repository to learn fractal generation algorithms.
Repository to learn fractal generation algorithms.

Fractalrs Created this project so I can study Rust while programming fractals! I have always wanted to learn fractal generation. Fractals Fractals are

Construct complex structures within single call + simple compile-time meta-inheritance model with mixins.

Introduction constructivism is a Rust sample-library designed to simplify the construction of structured data by defining and manipulating sequences o

Single-side boolean deserializers.

serde-bool Single value, true or false, boolean deserializers. Examples Supporting serde untagged enums where only one boolean value is valid, allowin

Scans a given directory for software of unknown provinence (SOUP) and dumps them in a json-file

Scans a given directory for software of unknown provinence (SOUP) and writes them to a json-file. The json-file contains name, version and a meta property for each SOUP.

The utility is designed to check the availability of peers and automatically update them in the Yggdrasil configuration file, as well as using the admin API - addPeer method.

Yggrasil network peers checker / updater The utility is designed to check the availability of peers and automatically update them in the Yggdrasil con

A minimal and fast zero-copy parser for the PE32+ file format.

peview A minimal and fast zero-copy parser for the PE32+ file format. Goal This project aims to offer a more light weight and easier to use alternativ

A parser for the .map file included in the aimware leak
A parser for the .map file included in the aimware leak

a utility I wrote to parse the map file included with the recent aimware self-leak. there is also an IDAPython script to import the symbol information into IDA.

Generate SUMMARY.md files based on your book's file structure

mdbook-autosummary Generate a SUMMARY.md for your mdBook based on your folder structure! Warning The implementation is hacky and has several limitatio

Owner
Akira Hayakawa
I am just a very good Rust programmer.
Akira Hayakawa
Shows how to implement USB device on RP2040 in Rust, in a single file, with no hidden parts.

Rust RP2040 USB Device Example This is a worked example of implementing a USB device on the RP2040 microcontroller, in Rust. It is designed to be easy

Cliff L. Biffle 9 Dec 7, 2022
A crate for converting an ASCII text string or file to a single unicode character

A crate for converting an ASCII text string or file to a single unicode character. Also provides a macro to embed encoded source code into a Rust source file. Can also do the same to Python code while still letting the code run as before by wrapping it in a decoder.

Johanna Sörngård 17 Dec 31, 2022
Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer.

Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer ?? Download | Give it a Star ⭐ | Share it on Twitte

Julio Andres 73 Jun 15, 2023
This repository contains the source of "The Rust Programming Language" book.

The Rust Programming Language This repository contains the source of "The Rust Programming Language" book. The book is available in dead-tree form fro

The Rust Programming Language 11.2k Jan 8, 2023
A repository for showcasing my knowledge of the Rust programming language, and continuing to learn the language.

Learning Rust I started learning the Rust programming language before using GitHub, but increased its usage afterwards. I have found it to be a fast a

Sean P. Myrick V19.1.7.2 2 Nov 8, 2022
The ray tracer challenge in rust - Repository to follow my development of "The Raytracer Challenge" book by Jamis Buck in the language Rust

The Ray Tracer Challenge This repository contains all the code written, while step by implementing Ray Tracer, based on the book "The Ray Tracer Chall

Jakob Westhoff 54 Dec 25, 2022
This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition

Overview This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

chuan 549 Dec 26, 2022
This repository serves as the backend for the Torrust Index project.

Torrust Index Backend ?? Important Updates ?? None at the moment ACCESS ALL UPDATES Index PROJECT DESCRIPTION PROJECT ROADMAP DOCUMENTATION INSTALLATI

Torrust 6 Dec 15, 2022
In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang.

Learn Rust What is this? In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang. This is usef

Domagoj Ratko 5 Nov 5, 2022
Rust template repository.

Rust template repository. An opinionated starting point for rust projects such as systemd services command line tools client programs server programs

Kris Nóva 42 Dec 28, 2022