GithubHelp home page GithubHelp logo

rust_practice's Introduction

rust_practice

#[derive(SomeName)] is an attribute that can only be applied to struct/enum/union type definitions, and it then applies the SomeName procedural macro (called a derive macro) to the source code that makes the type definition. The macro can then output / spit / emit its own forged source code, that will be emitted next to the original type definition source, which remains unaffected by the macro.

TODO

Modeling of Actions (pseudo-rust)

// This code requries more thinking and simplifying

struct User {
    id : i32;
    name : String
    ...
}


trait Action<Model> {
    type Model;
    const REQUIRED_PERMISSIONS : Permission;
    fn do(Model);
}

struct InsertModelInDb<Model>; 

impl Action<Model> for InsertModelInDb<Model> {
    type Model = Model;
    const REQUIRED_PERMISSIONS : Permissions = Permission::READ | Permission::CREATE;
    fn do(m : Model) {...}
}


// should be even simpler than this
#[route(post, /user)]
fn(s : SessionInfo, u : User) -> Result<(), Error> {
    if satisfies(InsertModelInDb::REQUIRED_PERMISSIONS, u.get_permissions(s.user.group))
        InsertModelInDb::do(u);
    else
        return Err("Permissions not satisfied")
}

rust_practice's People

Contributors

nkoturovic avatar

Watchers

 avatar  avatar

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.