service-io is a library to build servers that offering services with really little effort.

  1. Choose an input method
  2. Choose an output method.
  3. Choose your services.
  4. Run it!

One of the main use-cases is to offer services without a hosting server.

How it works?

All of them, inputs / outputs and services "speak" the same language: the Message type.

Inputs obtain and transform input data into a Message. Services receive Messages and generate other Messages usually doing some kind of processing. Outputs transform a Message into output data and deliver it.

Check the current built-in connectors and services.

Features

Getting Started

Add the following to your Cargo.toml toml service-io = "0.1"

Example

Simply send an email (as an example, to services@domain.com) with public-ip in the subject and you will obtain a response with your public ip!

```rust,norun use serviceio::engine::Engine; use serviceio::connectors::{ImapClient, SmtpClient}; use serviceio::services::PublicIp;

[tokio::main]

async fn main() { Engine::default() .input( ImapClient::default() .domain("imap.domain.com") .email("services@domain.com") .password("1234") ) .output( SmtpClient::default() .domain("smtp.domain.com") .email("services@domain.com") .password("1234") ) .add_service("public-ip", PublicIp) // Add any other service you want .run() .await; } ```

Any email sent to services@domain.com will be interpreted as a request by the ImapClient connector. If the first word of the subject matches public-ip, the request will be processed by the PublicIp service. The service PublicIp will generate a response that SmtpClient will be deliver by email to the remitter of the request email.

Check the Engine type for additional methods as input mapping/filters or adding whitelists to your services.

Test it yourself with examples/email_server.rs. Run the following to see all config options. sh cargo run --example email_server -- --help

Configuring a gmail account to use with service-io.

For use service-io with IMAP and SMTP connectors with gmail you need to configure some points of your gmail account: - Enable IMAP in account settings: Check this Step 1. - Enable unsecure app access to allow login with password from an app. (Pending work to make it available through oauth2 and avoid this point).

No hosting server use-case

If you want to offer some custom service that uses custom server code you are forced to pay and maintain a hosting server, even if the service you are offering is eventual or does not use many resources.

To solve this problem, you can use the already existent email infrastructure using the IMAP and SMTP protocols to handle the emails as requests / responses and link them with your services.

service-io helps in this context. Run locally an instance of service-io with IMAP/SMTP connectors. The IMAP connector will periodically fetch the emails your clients sends, then your services will process those emails and generate a response, and finally the SMTP connector will deliver the response emails back to the user.

Anyone from any device with an email client can interact with your local server deployment. There is no hosting maintenance and no front-end app development.

Contribute