Code Monkey home page Code Monkey logo

plugin-system's Introduction

Adapter

Warning

This library is in no way production ready.

Adapter is a library meant for providing a standard interface for which one can communicate with a variety of interfaces or plugins. It was created from a desire to be able to configure programs with a variety of different languages.

To see the thought process behind this, see RAMBLINGS.md.

The key concept of this library is the Adapter trait. It hinges on the idea that communicating with a foreign interface should be as simple as a function that has an input and an output (similar to a tower service). We use an identifier to determine the "endpoint" that we want to access.

pub trait Adapter<'a, Input, Output, Identifier> {
    type Error;

    fn call(&'a mut self, identifier: Identifier, input: Input) -> Result<Output, Self::Error>;
}

An adapter is generic over the input, output, identifier that is uses. It must take the input, and an identifier, and return a result with the output and the error.

Any restrictions for types must be applied in the implementation of the type (that is also probably generic over the input, output and identifier).

When using multiple adapters, one must constrain the input, output and identifier to types that meet the requirements of all the adapter's in use. Common types for these may be String and &str.

plugin-system's People

Contributors

sjcobb2022 avatar

Stargazers

Steve Manuel avatar  avatar Sheng Pang avatar

Watchers

 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.