Skip to main content

Probe

Struct Probe 

Source
pub struct Probe {
    pub dir: PathBuf,
    pub src_path: PathBuf,
    pub dot_line: u32,
    pub dot_col: u32,
}
Expand description

Represents an ephemeral Cargo project written to disk for LSP interrogation.

Deletes itself automatically when dropped.

Fields§

§dir: PathBuf

The absolute path to the root directory of the temporary Cargo project.

§src_path: PathBuf

The absolute path to the generated src/main.rs file.

§dot_line: u32

The 0-indexed line number in src/main.rs pointing to the target interaction point (the dot trigger).

§dot_col: u32

The 0-indexed character/column offset pointing exactly after the dot (_x.) in src/main.rs.

Implementations§

Source§

impl Probe

Source

pub fn new(type_name: &str) -> Result<Self>

Creates a new probe project without dependencies (for stdlib types).

§Errors

Returns an std::io::Error if creating the underlying probe project directory or writing its files fails.

Source

pub fn new_with_deps(type_name: &str, deps: Option<&str>) -> Result<Self>

Creates a new probe project with optional dependencies (for 3rd party crates).

§Arguments
  • type_name - The Rust type to query (e.g., “Vec<u8>”, “serde_json::Value”)
  • deps - Optional TOML dependencies section (e.g., “serde_json = "1.0"”)
§Errors

Returns an std::io::Error if generating the probe files or writing the dependency configuration fails.

Source

pub fn for_definition(type_name: &str, method_name: &str) -> Result<Self>

Creates a probe file with _x.METHOD_NAME() for go-to-definition queries. The cursor position points at the start of the method name.

§Errors

Returns an std::io::Error if the workspace initialization or file creation fails on disk.

Source

pub fn for_definition_with_deps( type_name: &str, method_name: &str, deps: Option<&str>, ) -> Result<Self>

Creates a probe file for go-to-definition with custom dependencies.

§Errors

Returns an std::io::Error if the underlying project boilerplate, file buffers, or custom dependency sections cannot be written.

Source

pub fn src_uri(&self) -> String

Converts the generated src/main.rs file path into a formatted file:// URI string.

Useful for protocols like LSP that require document paths formatted as URLs.

Source

pub fn root_uri(&self) -> String

Converts the root workspace directory path into a formatted file:// URI string.

Source

pub fn source(&self) -> Result<String>

Reads and returns the contents of the source file as a string.

§Errors

This function will return an Err if the file cannot be read. Common reasons include:

  • The file at src_path does not exist.
  • The user lacks permissions to read the file.
  • The file contents are not valid UTF-8.

Trait Implementations§

Source§

impl Drop for Probe

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Freeze for Probe

§

impl RefUnwindSafe for Probe

§

impl Send for Probe

§

impl Sync for Probe

§

impl Unpin for Probe

§

impl UnsafeUnpin for Probe

§

impl UnwindSafe for Probe

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> 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, 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.