diff options
| author | zhang san <[email protected]> | 2025-12-08 18:34:25 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-08 18:34:25 +0800 |
| commit | 69980f8b9d29b38dbd4ddf6373b4b45f3a138409 (patch) | |
| tree | 21dd9a8ce80e3d30192e9ffa56ea39a199bae309 /components/rust/core/src/lib.rs | |
| parent | cd1d47b87c5d47e131730e5506eb3ad77d357653 (diff) | |
Adding Rust Language Support for RT-Thread #10910
Diffstat (limited to 'components/rust/core/src/lib.rs')
| -rw-r--r-- | components/rust/core/src/lib.rs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/components/rust/core/src/lib.rs b/components/rust/core/src/lib.rs new file mode 100644 index 0000000000..2787b7240a --- /dev/null +++ b/components/rust/core/src/lib.rs @@ -0,0 +1,83 @@ +/* + * 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(alloc_error_handler)] +#![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; +pub mod fs; +pub mod panic; +pub mod param; +pub mod queue; +pub mod sem; +pub mod thread; +pub mod time; +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, + + FuncUnDefine, +} + +pub type RTResult<T> = Result<T, RTTError>; |
