Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

It’s just a tool library.

If you just want to use the library, check out Getting Started.

If you would like to join the development, please check out the design documentation.

Getting Started

Design Documentation

This is the design documentation for the project. If you are not familiar with the project, please read the Getting Started first.

Design Goals

Design a modular, ergonomic, and universal tool library

Architecture

See Architecture

Task System

See Task System

I18n

Backends

Task System

Task Priority

  1. Realtime
  2. High
  3. Normal
  4. Low
  5. Idle

Task Scheduler

  1. System

SIMD

fn main() {
  let datas = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  datas.simd_task_iter()
    .add(1)
}

Pipeline

use algosul::cpu::task::prelude::v1::*;
fn main() {
  let datas = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  datas.task_iter()
    .filter(|x| x % 2 == 0)
    .sync_task(100)
    .map(|x| x * 10)
}

Commands

Rust Derive

Undo/Redo

Modules

Module Manager

Module ID

Module Private ID

Messages

Message Type

Basic type, does not support sending:

  • Debug
  • Info
  • Warn
  • Error

To define message types, you must choose to inherit from a message type

Message Content

Needs to implement Message Trait

Message Metadata

  • Status (status):
    • Succeed
    • Failed
  • Process (process): 0% ~ 100%
    • Progress detail (progress_detail):0/32, loading...

Message Sender

Message

Message interface

  • Send message function
  • Register message type functions
  • Register the message hook function

Message Trait

Application

Applications

Rust

Dependencies

Mirrors

  1. https://mirrors.tuna.tsinghua.edu.cn/rustup/dist
  2. https://rsproxy.cn/rustup

Install Rust

Reference: https://forge.rust-lang.org/infra/other-installation-methods.html

Standalone Installers (Rustup)

  1. Check the system environment
  2. List Rust versions ( https://static.rust-lang.org/dist/channel-rust-stable.toml )
  3. Download the installation package for the corresponding version. ( https://static.rust-lang.org/rustup/dist/{TARGET_TRIPLE}/rustup-init{.exe?} )
  4. Install to the designated location
  5. Check the installation status

Standalone Installers (No Rustup)

  1. Check the system environment
  2. List Rust versions ( https://static.rust-lang.org/dist/channel-rust-stable.toml )
  3. Download the installation package for the corresponding version. ( https://static.rust-lang.org/rustup/dist/rustc-{VERSION}-{TARGET_TRIPLE}.tar.xz )
  4. Unzip the installation package
  5. Install to the designated location
  6. Check the installation status

Source Code (No Rustup)

  1. Choose Host Rust versions
  2. Check the system environment
  3. List Rust Source versions ( https://static.rust-lang.org/dist/channel-rust-stable.toml )
  4. Download the source code ( https://static.rust-lang.org/dist/rustc-{VERSION}-src.tar.xz )
  5. Unzip the source code
  6. Compile the source code
  7. Install to the designated location (or system link)
  8. Check the installation status

Uninstall Rust

Rustup

  1. Run rustup self uninstall
  2. Check the uninstallation status

Source Code

  1. Remove the installation files (or system link)
  2. Clean the source code directory (optional)
  3. Check the uninstallation status

Update Rust

Rustup

  1. Run rustup update

Source Code

  1. Choose Host Rust versions
  2. Check the system environment
  3. List Rust Source versions ( https://static.rust-lang.org/dist/channel-rust-stable.toml )
  4. Download the source code ( https://static.rust-lang.org/dist/rustc-{VERSION}-src.tar.xz )
  5. Unzip the source code (Overwrite)
  6. Compile the source code
  7. Install to the designated location (or system link)
  8. Check the installation status

LLVM

GCC

Python

GDB

LLDB

Git

Jujutsu

Version

Authors

Derive

User Interface(UI)

v1

#![allow(unused)]
fn main() {
use std::net::SocketAddr;
use std::time::Duration;
use algosul::ui::*;
use algosul::derive::*;

#[derive(UI, DataSync)]
#[ui(key = "time-sync", widget = "Taps::new()")]
enum TimeSync {
  #[ui(title_key = "unknown")]
  #[ui_cfg(class = "show", widget = "Text::new()")]
  #[ui_cfg(class = "input", ignore)]
  Unknown,
  #[ui(title_key = "no-sync")]
  No,
  #[ui(title_key = "auto-sync")]
  Auto {
    url: String,
    refresh_duration: Duration,
  }
}
}

v2

  1. async + Rc<RefCell<T>>
  2. Sender and Receiver
#![allow(unused)]
fn main() {
use algosul::{ui::*, derive::*};
#[derive(DataSync)]
enum TimeSync {
  Unknown,
  No,
  Auto {
    url: String,
    refresh_duration: Duration,
  }
}

impl Widget for TimeSync {
  fn build(&self) -> Box<dyn Widget> {}
}

}

Utilities

Process

I/O

Virtual File System (VFS)

TypeIdentifier
File SystemFileSystem
PathPath
FileFile
DirectoryDirectory
DeviceDevice
SocketSocket

Base Directory

See XDG Base Directory Specification

Regardless of the platform, check the environment variable XDG_XYZ_ABC, If it exists, use the folder defined by the environment variable, Otherwise, use the platform’s default folder

All paths set in these environment variables must be absolute. If an implementation encounters a relative path in any of these variables it should consider the path invalid and ignore it.

Variables that may be used:

  • {USER}: Username (Unix-like: environment variable USER, Windows: environment variable USER_NAME)
  • {UID}: User ID (Only in Unix-like)
  • {APP_NAME}: Application Name
  • {APPDATA}: environment variable APPDATA (Only in Windows)
  • {LOCALAPPDATA}: environment variable LOCALAPPDATA (Only in Windows)

User-specific Data

XDG: XDG_DATA_HOME:

  • Unix-like: ~/.local/share/{APP_NAME}
  • Windows: {APPDATA}/{APP_NAME}/data
  • MacOS: ~/Library/Application Support/

User-specific Configuration

XDG: XDG_CONFIG_HOME

  • Unix-like: ~/.config/{APP_NAME}
  • Windows: {APPDATA}/{APP_NAME}/config
  • MacOS: ~/Library/Preferences/

User-specific State Data

XDG: XDG_STATE_HOME:

  • Unix-like: ~/.local/state/{APP_NAME}
  • Windows: {LOCALAPPDATA}/{APP_NAME}/state
  • MacOS: ~/Library/Application Support/

User-specific Cached Data

XDG: XDG_CACHE_HOME:

  • Unix-like: ~/.cache/{APP_NAME}
  • Windows: {LOCALAPPDATA}/{APP_NAME}/cache
  • MacOS: ~/Library/Caches/

User-specific Runtime Files

XDG: XDG_RUNTIME_DIR:

  • Linux: /run/user/{UID}
  • Windows: %TEMP%
  • MacOS: $TMPDIR
  • Unix-like: /var/run/user/{UID}

System Runtime Files

Similar to this rust: std::env::temp_dir()

  • Linux: /tmp
    • Android: Decided by the system
  • Windows: GetTempPath2/GetTempPath
  • MacOS: confstr(_CS_DARWIN_USER_TEMP_DIR, ...)
  • Unix-like: /tmp

Async

Process

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph BT
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  ACommand[AsyncCommand]
  
  AChild[AsyncChild]
  
  AIsTerminal{AsyncIsTerminal}:::interface

I/O

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph BT
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  ARead{AsyncRead}:::interface
  
  ABufRead{AsyncBufRead}:::interface
  
  AWrite{AsyncWrite}:::interface
  
  ASeek{AsyncSeek}:::interface


Target

Introduction

‘target’ indicates the target platform on which the software runs

includes:

Specification

Architectures

bits3264
x86i586/i686x86_64
aarcharm (aarch32)aarch64
loongarchloongarch32loongarch64
riscvriscv32imacriscv64gc

Operating Systems (OS)


Unix

linux: Linux

  • android: Google Android
  • unknown: Others

apple: Apple

  • darwin: macOS
  • ios: iOS
  • watchos: Apple Watch OS
  • tvos: Apple TV OS
  • visionos: Apple Vision OS

BSD

  • unknown-freebsd: FreeBSD
  • unknown-netbsd: NetBSD
  • unknown-openbsd: OpenBSD

Windows

  • pc-windows: Windows
  • uwp-windows: Windows Universal Platform

Vendor

ABI

Data Layout

Adapter

LLVM Target

  • <arch>-<vendor>-<os>-<abi>

Rust Target

  • <arch>-<vendor>-<os>-<abi>

Math

User Interface (UI)

View

Cargo Plugin (cargo-algosul)

Project Manage

Project Init

Project Build

Project Test

Project Clean

Project Run

Project Debug

IDE Plugins

IDEA (IntelliJ) Plugin

VSCode Plugin

Architecture

It is recommended to use dark themes

1. Overall Architecture

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;

  Core:::core
  
  I18n:::core

  Modules:::modules

  Messages:::messages
  
  CPU:::api
  GPU:::api
  NPU:::api
  
  UI:::ui
  AI:::ai

  AI --> NPU & GPU & CPU --> Messages
  UI --> GPU & CPU --> Messages

  Messages --> Modules --> I18n --> Core

UI

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;

  UI:::ui
  
  UIFramework[UI Framework]:::ui
  UIBackend{UI Backend}:::interface
  
  DefaultUIBackend[Default UI Backend]:::ui
  
  RenderPipeline[Render Pipeline]:::ui

  RenderPipelineInterface{Render Pipeline Interface}:::interface
  
  DefaultUIBackend --> UIBackend
  DefaultUIBackend --> RenderPipeline 
  UI --> UIBackend & UIFramework
  
  RenderPipeline --> RenderPipelineInterface

Backends

  • algosul::cpu
  • algosul::gpu
  • Qt 6
  • Gtk 4
  • WinUI 2

AI

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;

  AI:::ai
  
  AIInference[AI Inference]:::ai
  
  AIInferenceInterface{AI Inference Interface}:::interface

  AI --> AIInference
  
  AIInference --> AIInferenceInterface
  

Render

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  CPURenderPipeline[CPU Render Pipeline]:::ui
  GPURenderPipeline[GPU Render Pipeline]:::ui
  
  RenderPipelineInterface{Render Pipeline Interface}:::interface
  
  CPU:::api
  GPU:::api
  
  CPURenderPipeline & GPURenderPipeline --> RenderPipelineInterface
  
  CPURenderPipeline ---> CPU
  GPURenderPipeline ---> GPU

AI Inference

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  CPUAIInference[CPU AI Inference]:::ai
  GPUAIInference[GPU AI Inference]:::ai
  
  AIInferenceInterface{AI Inference Interface}:::interface
  
  CPU:::api
  GPU:::api
  
  CPUAIInference & GPUAIInference --> AIInferenceInterface 
  
  CPUAIInference ---> CPU 
  GPUAIInference ---> GPU

CPU

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  CPU:::api
  
  Task{Task System}:::interface
  
  CPU -..-> Task
  

GPU

%%{
  init: {
    'theme': 'redux dark', 
  }
}%%
graph TB
  classDef interface fill:#822, stroke: #f88,stroke-width:2px,stroke-dasharray: 5 5, color: #fff;
classDef core fill:#828, stroke: #f8f, stroke-width:2px, color: #fff;
classDef modules fill:#228, stroke: #88f,stroke-width:2px, color: #fff;
classDef messages fill:#882, stroke: #ff8,stroke-width:2px, color: #fff;
classDef api fill:#282, stroke: #8f8,stroke-width:2px, color: #fff;
classDef ai fill:#288, stroke: #8ff,stroke-width:2px, color: #fff;
classDef ui fill:#852, stroke: #fb8,stroke-width:2px, color: #fff;
  
  GPU:::api
  
  Cuda:::api
  Vulkan:::api
  DirectX:::api
  Task{Task System}:::interface
  
  GPU  --> Vulkan & DirectX & Cuda
  GPU -..-> Task
  
  Vulkan & DirectX -.-> Cuda