Function tauri::api::file::read_string

source ·
pub fn read_string<P: AsRef<Path>>(file: P) -> Result<String>
Expand description

Reads the entire contents of a file into a string.

Examples found in repository?
src/endpoints/file_system.rs (line 157)
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
  fn read_text_file<R: Runtime>(
    context: InvokeContext<R>,
    path: SafePathBuf,
    options: Option<FileOperationOptions>,
  ) -> super::Result<String> {
    let resolved_path = resolve_path(
      &context.config,
      &context.package_info,
      &context.window,
      path,
      options.and_then(|o| o.dir),
    )?;
    file::read_string(&resolved_path)
      .with_context(|| format!("path: {}", resolved_path.display()))
      .map_err(Into::into)
  }