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: PathBufThe absolute path to the root directory of the temporary Cargo project.
src_path: PathBufThe absolute path to the generated src/main.rs file.
dot_line: u32The 0-indexed line number in src/main.rs pointing to the target interaction point (the dot trigger).
dot_col: u32The 0-indexed character/column offset pointing exactly after the dot (_x.) in src/main.rs.
Implementations§
Source§impl Probe
impl Probe
Sourcepub fn new(type_name: &str) -> Result<Self>
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.
Sourcepub fn new_with_deps(type_name: &str, deps: Option<&str>) -> Result<Self>
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.
Sourcepub fn for_definition(type_name: &str, method_name: &str) -> Result<Self>
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.
Sourcepub fn for_definition_with_deps(
type_name: &str,
method_name: &str,
deps: Option<&str>,
) -> Result<Self>
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.
Sourcepub fn src_uri(&self) -> String
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.
Sourcepub fn root_uri(&self) -> String
pub fn root_uri(&self) -> String
Converts the root workspace directory path into a formatted file:// URI string.
Sourcepub fn source(&self) -> Result<String>
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_pathdoes not exist. - The user lacks permissions to read the file.
- The file contents are not valid UTF-8.