file_operation/file/
impl.rs

1use crate::*;
2
3/// Provides conversion implementation from byte vector to FileDataString.
4impl From<Vec<u8>> for FileDataString {
5    /// Converts a byte vector to FileDataString.
6    ///
7    /// # Arguments
8    ///
9    /// - `Vec<u8>` - The byte vector to convert.
10    ///
11    /// # Returns
12    ///
13    /// - `FileDataString` - The converted string wrapper.
14    fn from(bytes: Vec<u8>) -> Self {
15        FileDataString(String::from_utf8(bytes).unwrap_or_else(|_| String::new()))
16    }
17}
18
19/// Provides Display trait implementation for FileDataString.
20impl fmt::Display for FileDataString {
21    /// Formats the FileDataString for display.
22    ///
23    /// # Arguments
24    ///
25    /// - `&mut fmt::Formatter<'_>` - The formatter to write to.
26    ///
27    /// # Returns
28    ///
29    /// - `fmt::Result` - The result of the formatting operation.
30    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31        write!(f, "{}", self.0)
32    }
33}