Skip to content

vernisaz/rust_dev_studio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

620 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Development Studio - CGI

Purpose

Web interfaced IDE for a development primarily in Rust. The IDE can run locally or on a cloud machine. It can be accessed from any device having an HTML5 capable browser. It's perfect for tablets like Amazon Fire and others.

The approach of a web based IDE becomes popular nowadays, for example - Code anywhere with Android Studio Cloud.

Features

  • multi windows editor with syntax highlighting
  • a notepad with two ways copying
  • source code bookmarking
  • identifier case conversion, as camel, snake and so on
  • code analyzer with function names, usage points, and autocomplete
  • search across all project files
  • full Unix terminal for all supported platforms
  • integration with Rust toolchain as a compiler, Rustfmt, Clippy, Rustdoc, and Cargo
  • seamless access to error lines in the editor from the terminal error reporting content
  • possibility to use with any other programming language(s)
  • full git integration
  • mobile and desktop browsers support
  • blazing fast and safe Rust implementation
  • scalable, multi megabytes projects can be easily handled
  • includes all required components as a web server, a scripting tool, and a terminal for all supported platforms

Architecture

The client part is quite obvious and utilizes HTML 5, CSS and JavaScript. But the server part resurrects the forgotten CGI technology which is perfectly suitable for using Rust. The terminal functionality is implemented using a websocket endpoint. So the RDS has written in Rust, HTML, CSS, and JavaScript and runs on the Rust web server.

Implementation

It's a really compact with a footprint below 10 MB. All web requests are handled by one Rust CGI executable. The terminal is a websocket endpoint utilizing the WS-CGI technology.

Quick start

If you plan to give the project a try, just go to releases section on GitHub and download zip file for your platform. Unzip the file in a command window and type ./rds.sh (.\rds on Windows) in the unzipped directory. You're ready to go after answering a couple questions. File rds.url contains the access URL. Just copy it in your browser address bar and start using the RDS.

Config

The following configuration snippet has to be added to env.conf of the SimHTTP Rust web server:

"mapping" : [
  {"path":"/cgires/resource",
       "translated": "./../rust_dev_studio/src/html"},
       {"path":"/cgires/resource/ace",
       "translated": "./../side/ace-builds/src-min-noconflict"},
      {"path":"/rustcgi",
       "CGI": true,
       "translated": "./../rust_dev_studio"},
      {"path":"/cgires/resource/terminal",
       "translated": "./../simterminal/src/js"},
      {"path":"/terminal",
       "WS-CGI": true,
       "translated": "./../rust_dev_studio/terminal"}]

The mapping is used to run the RDS from the dev environment, therefore an access URL looks like http://orangepi5:3000/rustcgi/rustcgi/src/html?session=rds&, however a simpler form is used in the standard packaging as http://orangepi5:3000/rustcgi/rustcgi?session=rds&. A port and a host name will depend on your environment. Even CGI mapping can be changed.

Make sure that translated paths are valid in the underline OS and they can be related to the directory the server started from.

File .config residing in the same directory, where rustcgi executable is stored, is required. The file has to specify a fully qualified path to the common config directory where RDS lands the directory .rds.

Directory .rds may contain file .workspace which contains a path to the directory where all projects used by RDS are landed. If there is no such file presented, then the workspace directory will be the same as specified in the .config file. For example a user HOME directory can be provided in the .config file.

Also, directory .rds can include file aliases.prop. The file contains entries in a form like :

alias alias_name='command arguments...'

It is a standard alias syntax of Unix shell allowing to setup an alias for the RDS terminal.

You are free to use any other web server capable to run CGI scripts. But the terminal can be used only with the SimHTTP, because the server provides the WS CGI support.

There is a Java terminal websocket endpoint built on JSR 356 technology. It's out of a support, but still can be obtained from there.

Ace Cloud editor

The Rust Development Studio is loosely coupled with Ace (Ajax.org Cloud9) Editor.

RDS is coming bundled with some version of the Ace editor. You can always bundle it with any other version of the editor. Go to Ace and download the desired version. A copy of it has to be placed in the directory resource/ace inside RDS directory. It's reflected in the installation script.

Building RDS components

The RustBee scripting tool is used for building. Obtain it first.

The following crates are required for building the product:

The crates directory on the level of repository directories has to be created prior building unless it's already there. Run rb in each crate repository.

Finally bee.7b script used for building RDS, and bee-term.7b script used to build the terminal.

The terminal functionality is separated in the crate SimTerminal, therefore build it before building the terminal and then build the terminal. Note that the crate has one extra dependency the Simple Color which should be built earlier.

Packaging

Although you can configure the development studio yourself accordingly to a web server and other components location, there is the predefined packaging.

The packaging can be created by running a RustBee script. The created zip file can be unzipped in any desired location and then launch ./rds.sh or .\rds.bat on Windows and start using the RDS. The access URL's stored in rds.url.

Usage tips

You will see an empty page when first time pointed a browser to the RDS URL. Select menu File/Project/New.... Navigate to a project directory and then Apply for the new project. Open the just created project from menu File/Project/<name> then. You can start to navigate over the project tree, open and edit files, build its components and so on.

If you do not have a project checked out or created yet, then you can use the terminal panel and execute underline OS commands as mkdir, git clone, or cargo new my_rds_project --bin. Note, that creating a project in RDS will create a project directory, unless it exists. You can always correct the project root directory in the Settings. Note that RDS starting from version 1.52 is capable to checkout a project from GIT repository as a part of its creation.
You can also delete any undesired projects in Settings. However it deletes only references to the project and you will need to delete project files manually using the terminal panel when it's required.

RDS text editor operates with files in UTF-8 encoding, therefore, if you migrate some project to RDS with files in other encodings, they can be not opened. You need to convert such files in UTF-8. Unless the files have long fragments in other encoding, you can use the tool for the task.

When you use Cargo to build a Rust project, make sure to set CARGO_TERM_COLOR env variable to always. It is controlled also by term.color of Cargo settings. For example:

[term]
color=always

Note that RDS is a web UI, it means that most operations will end at accessing a remote host. It can take time and be costly, therefore RDS minimizes an ammount of such operations. As result, a visible state of the project and the actual state can go out of the sync. Therefore, do not hesitate to use Edit/Reload when you have doubts. Since calling Reload will discard all changes done in the tab, you may save the tab content first to a new file.

Running Rustfmt and other Rust formatters from RDS

Since RDS is a new IDE, it isn't covered in this document. RDS allows to run Rustfmt explicitly selecting it from menu Source/Format, or implicitly checking off Format on save in Settings. In both cases, Rustfmt has to be configured in Project/Config... . You can specify a formatting program, e.g. rustfmt, and its options, for example:

rustfmt --edition 2024

If a formatting on save didn't happen for some reason, the file will be saved as is. All error reporting at format on save remains in a web server log, therefore you can temporaly disable a format on save in cases when no formatting happens and do it explicitly to see formatting errors in the IDE. If more than one file is autosaved with formatting, some files can be not updated in the RDS UI in Safari, so do it manually using menu Edit/Reload.

You are not limited to using Rustfmt, and you can use other Rust formatters, for example Rustidy. Just specify it in the configuration as

rustidy

An absolute path to the program can be required, unless it's accessible from PATH.

Documenting a project

You can use rustdoc for documenting an application or a crate. You need to specify a way of calling rustdoc or a similar purpose tool. Since a different documenting tool can be used, you need to specify it in Project/Config....

Viewing the documentation is convinient in the same browser and from the same web server as RDS runs from. Add the following entry in the mapping section of env.conf of SimHTTP:

    {"path":"/doc",
    "translated": "../docs"}

A link to view the documentation will be shown on a console when RB scripts are used. A mapping entry to HOME/rust_docs in env.confgets added automatically by the RDS installation script. You can modify the entry accordingly your real documentation directory location.

Cloud and multi users install

If you plan to use the IDE on a Cloud in the multi users environment, then you need to provide a proxy server in the front of RDS which provides:

  • Decryption/Re-encryption (SSL Proxy)
  • A user authentication
  • URL translation
  • Reject a brutal force and other cyber attacks

For example, a Cloud URL in the form - https://ide.cloud.com/user-name gets translated to http://internalhost:3000/, the IDE uses only URLs in a relative form and doesn't need to know how an actual URL looks when it got accessed.

Browser Compatibility

RDS uses HTML 5 features presented in popular browsers today. Compatibility was tested using the latest Firefox, Edge, Safari, and Amazon Silk browsers. More likely, other browsers will work too. If you encounter problems with your browser, then, please, report them to the author.

Like the IDE but Rust

You can add any other language in the support. Open main.html and navigate to around line 288 to see

const EDITOR_MODE = {

Add more modes accordingly a file extension of the code type of your interest.

If you need to navigate in a source code from error messages for the language compiler in the terminal, look for

var fileNameReg

around line 398. Add a desired language file extension in the regular expression definition in the context (rs|swift|java|7b).

Version

The current version is 1.52.02. You can also check out the current development code, however it can be not stable.

Known problems

  1. files can stop to be opened from the left navigation panel (work around - select Refresh Proj from Edit menu or reload the RDS browser window)
  2. A file tab can appear empty after the auto restore tabs in Safari. Just select Edit/Reload to get its content.

Reading about

  1. Some light on used technologies.

Help wanted

If you like the IDE and want to contribute to its development, please contact me using the standard github communication way. Entry level people are welcome, because you will use the vibe programming.

Current tasks:

  1. Build AI engine on different principles than ChatGPT

About

Web based IDE written in Rust

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors