#[repr(C)]pub struct ModuleProbe {
pub id: [u8; 64],
pub name: [u8; 128],
pub version: Version,
pub api_version: Version,
pub rustc_version: [u8; 64],
pub required_deps_count: u8,
pub required_deps: [[u8; 64]; 8],
pub optional_deps_count: u8,
pub optional_deps: [[u8; 64]; 8],
}Expand description
FFI-safe module probe for metadata discovery.
Linux equivalent: struct modinfo + vermagic string
This struct uses fixed-size arrays instead of pointers to avoid lifetime issues when the module is unloaded. All strings are null-terminated within their fixed buffers.
§FFI Safety
#[repr(C)]ensures predictable memory layout across dynamic library boundaries- Fixed-size arrays avoid pointer invalidation when module is unloaded
- All fields are Copy, no heap allocation required
- Can be returned by value across FFI boundary safely
§Buffer Sizes
id: 64 bytes (63 chars + nul) - module identifiername: 128 bytes (127 chars + nul) - display name
Strings exceeding these limits are truncated (not an error).
§Example
use reovim_kernel::api::v1::{ModuleProbe, Version};
let probe = ModuleProbe::new(
"lang-rust",
"Rust Language Support",
Version::new(1, 0, 0),
Version::new(1, 0, 0),
);
assert_eq!(probe.id_str(), "lang-rust");
assert_eq!(probe.name_str(), "Rust Language Support");Fields§
§id: [u8; 64]Module ID (null-terminated, max 63 chars + nul)
name: [u8; 128]Module name (null-terminated, max 127 chars + nul)
version: VersionModule version
api_version: VersionRequired kernel API version
rustc_version: [u8; 64]Rustc version used to compile the module (for ABI compatibility checks)
required_deps_count: u8Number of required dependencies (max 8)
required_deps: [[u8; 64]; 8]Required dependency IDs (null-terminated strings)
optional_deps_count: u8Number of optional dependencies (max 8)
optional_deps: [[u8; 64]; 8]Optional dependency IDs (null-terminated strings)
Implementations§
Source§impl ModuleProbe
impl ModuleProbe
Sourcepub const fn new(
id: &str,
name: &str,
version: Version,
api_version: Version,
) -> Self
pub const fn new( id: &str, name: &str, version: Version, api_version: Version, ) -> Self
Create a new probe with the given metadata.
Strings are truncated if they exceed buffer size. This is a const fn for use in static initialization.
§Example
use reovim_kernel::api::v1::{ModuleProbe, Version};
// Can be used in const context
const PROBE: ModuleProbe = ModuleProbe::new(
"my-module",
"My Module",
Version::new(1, 0, 0),
Version::new(1, 0, 0),
);Sourcepub fn id_str(&self) -> &str
pub fn id_str(&self) -> &str
Get module ID as string slice.
Returns the null-terminated string content from the fixed buffer.
Sourcepub fn name_str(&self) -> &str
pub fn name_str(&self) -> &str
Get module name as string slice.
Returns the null-terminated string content from the fixed buffer.
Sourcepub fn rustc_version_str(&self) -> &str
pub fn rustc_version_str(&self) -> &str
Get rustc version as string slice.
Returns empty string if not set.
Sourcepub fn required_deps(&self) -> Vec<ModuleId>
pub fn required_deps(&self) -> Vec<ModuleId>
Get required dependencies as ModuleId list.
Returns up to 8 dependencies stored in the probe.
Sourcepub fn optional_deps(&self) -> Vec<ModuleId>
pub fn optional_deps(&self) -> Vec<ModuleId>
Get optional dependencies as ModuleId list.
Returns up to 8 dependencies stored in the probe.
Sourcepub const fn with_rustc_version(self, version: &str) -> Self
pub const fn with_rustc_version(self, version: &str) -> Self
Set rustc version (builder pattern for const contexts).
§Example
use reovim_kernel::api::v1::{ModuleProbe, Version};
let probe = ModuleProbe::new("test", "Test", Version::new(1, 0, 0), Version::new(0, 2, 0))
.with_rustc_version("1.92.0");
assert_eq!(probe.rustc_version_str(), "1.92.0");Sourcepub const fn with_required_dep(self, index: usize, dep: &str) -> Self
pub const fn with_required_dep(self, index: usize, dep: &str) -> Self
Add a required dependency at the specified index (builder pattern).
Index must be 0-7. Silently ignored if index >= 8.
Sourcepub const fn with_optional_dep(self, index: usize, dep: &str) -> Self
pub const fn with_optional_dep(self, index: usize, dep: &str) -> Self
Add an optional dependency at the specified index (builder pattern).
Index must be 0-7. Silently ignored if index >= 8.
Trait Implementations§
Source§impl Clone for ModuleProbe
impl Clone for ModuleProbe
Source§fn clone(&self) -> ModuleProbe
fn clone(&self) -> ModuleProbe
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more