Skip to main content

ModuleProbe

Struct ModuleProbe 

Source
#[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 identifier
  • name: 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: Version

Module version

§api_version: Version

Required kernel API version

§rustc_version: [u8; 64]

Rustc version used to compile the module (for ABI compatibility checks)

§required_deps_count: u8

Number of required dependencies (max 8)

§required_deps: [[u8; 64]; 8]

Required dependency IDs (null-terminated strings)

§optional_deps_count: u8

Number of optional dependencies (max 8)

§optional_deps: [[u8; 64]; 8]

Optional dependency IDs (null-terminated strings)

Implementations§

Source§

impl ModuleProbe

Source

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),
);
Source

pub fn id_str(&self) -> &str

Get module ID as string slice.

Returns the null-terminated string content from the fixed buffer.

Source

pub fn name_str(&self) -> &str

Get module name as string slice.

Returns the null-terminated string content from the fixed buffer.

Source

pub fn rustc_version_str(&self) -> &str

Get rustc version as string slice.

Returns empty string if not set.

Source

pub fn required_deps(&self) -> Vec<ModuleId>

Get required dependencies as ModuleId list.

Returns up to 8 dependencies stored in the probe.

Source

pub fn optional_deps(&self) -> Vec<ModuleId>

Get optional dependencies as ModuleId list.

Returns up to 8 dependencies stored in the probe.

Source

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");
Source

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.

Source

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

Source§

fn clone(&self) -> ModuleProbe

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModuleProbe

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for ModuleProbe

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.