GithubHelp home page GithubHelp logo

sifis-home / datta Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 40 KB

Rust implementation of RFC6570 - URI Template that can process URI Templates up and to including ones designated Level 4.

License: BSD 3-Clause "New" or "Revised" License

Python 5.03% Rust 94.97%

datta's Introduction

datta

Build Status Cargo version Documentation dependency status License codecov

datta is a Rust implementation of RFC6570 - URI Template that can process URI Templates up to and including ones designated as Level 4 by the specification. It passes all of the tests in the uritemplate-test test suite.

It is a fork of rust-uritemplate.

Basic Usage

Variable setting can be chained for nice, clean code.

let uri = UriTemplate::new("/view/{object:1}/{/object,names}{?query*}")
    .set("object", "lakes")
    .set("names", &["Erie", "Superior", "Ontario"])
    .set("query", &[("size", "15"), ("lang", "en")])
    .build();

assert_eq!(uri, "/view/l/lakes/Erie,Superior,Ontario?size=15&lang=en");

It is not possible to set a variable to the value "undefined". Instead, simply delete the variable if you have already set it.

let mut t = UriTemplate::new("{hello}");
t.set("hello", "Hello World!");
assert_eq!(t.build(), "Hello%20World%21");

t.delete("hello");
assert_eq!(t.build(), "");

The delete function returns true if the variable existed and false otherwise.

Supported Types

Any type that implements IntoTemplateVar can be set as the value of a UriTemplate variable. The following implementations are provided by default for each type of variable:

  • Scalar Values: String, &str
  • Lists: Vec<String>, &[String], &[str]
  • Associative Arrays: Vec<(String, String)>, &[(String, String)], &[(&str, &str)], &HashMap<String, String>

In addition, you can implement IntoTemplateVar for your own types. View the documentation for IntoTemplateVar for information on how that works.

Acknowledgements

This software has been developed in the scope of the H2020 project SIFIS-Home with GA n. 952652.

datta's People

Contributors

dodomorandi avatar chowdhurya avatar lu-zero avatar badboy avatar

datta's Issues

Fix LICENSE file

GitHub is not able to recognize the LICENSE file. Probably there is something wrong with that, we should fix it using the actual BSD-3-Clause template.

Fix doctests

There are some ignored tests which does not pass if cargo test -- --ignored is run.

This can be pretty annoying, because code from docs is expected to run and pass.

Thin the current CI

The crate does not have os-specific codepaths so might be better to turn off macos and windows and move the extended check in the linux CI.

Move Miri check to a manual action

Miri takes a huge amount of time to run in CI. We are not using any unsafe code (we could also add a deny(unsafe) pragma @lu-zero), therefore it makes sense to keep it separated from the normal workflow.

It could be included in the pre-tag actions, just to have some stricter checks before publication.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.