Skip to main content

load_document_from_disk

Function load_document_from_disk 

Source
pub async fn load_document_from_disk(uri: &Uri) -> Result<String>
Expand description

Loads document content from disk.

§Arguments

  • uri - Document URI (must be file:// scheme)

§Returns

  • Ok(String) - File content
  • Err(DepsError) - File not found, permission denied, not a file URI, or too large/not a regular file

§Errors

  • DepsError::InvalidUri - URI is not a file:// URI
  • DepsError::Io - File read error (not found, permission denied, etc.)
  • DepsError::CacheError - Not a regular file, or exceeds MAX_FILE_SIZE

§Examples

use deps_lsp::document::load_document_from_disk;
use tower_lsp_server::ls_types::Uri;

let uri = Uri::from_file_path("/path/to/Cargo.toml").unwrap();
let content = load_document_from_disk(&uri).await?;
println!("Loaded {} bytes", content.len());