summaryrefslogtreecommitdiff
path: root/components/rust/core/src/lib.rs
blob: 0b94f81427cb388a6d94f435ee065a8975e81df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       notes
 * 2025-09-15     foxglove     1.0 version
 * 2025-09-25     foxglove     1.1 version
 * 2025-10-10     foxglove     latest version
 */

/* RT-Thread Rust core library

Provides basic system support functionality including file system, network,
and device interfaces. Designed for embedded devices running RT-Thread.
*/

#![no_std]
#![feature(linkage)]
#![allow(dead_code)]

pub extern crate alloc;

#[doc = "Alloc by rt-thread"]
#[global_allocator]
static GLOBAL: allocator::RttAlloc = allocator::RttAlloc;
pub mod api;
pub mod bindings;

pub mod init;
pub mod allocator;
pub mod mutex;
pub mod out;
#[cfg(feature = "fs")]
pub mod fs;
pub mod panic;
pub mod param;
pub mod queue;
pub mod sem;
pub mod thread;
pub mod time;
#[cfg(feature = "libdl")]
pub mod libloader;

mod prelude;
pub use prelude::v1::*;

/* Re-export initialization function */
pub use init::rust_init;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum RTTError {
    ThreadStartupErr,
    MutexTakeTimeout,
    SemaphoreTakeTimeout,
    QueueSendTimeout,
    QueueReceiveTimeout,
    OutOfMemory,

    DeviceNotFound,
    DeviceOpenFailed,
    DeviceCloseFailed,
    DeviceReadFailed,
    DeviceWriteFailed,
    DeviceTransFailed,
    DeviceConfigFailed,
    DeviceSetRxCallBackFailed,
    DeviceSetTxCallBackFailed,

    FileOpenErr,
    FileCloseErr,
    FileReadErr,
    FileWriteErr,
    FileSeekErr,
    FileFlushErr,
    FileDeleteErr,
    FileSetLengthErr,
    FileSyncErr,

    FuncUndefined,
}

pub type RTResult<T> = Result<T, RTTError>;