pub fn format_key(path: impl Into<PathBuf>) -> String {
    let path = path.into();

    // add in root to mimic how it is used from a server url
    let path = if path.has_root() {
      path
    } else {
      Path::new(&Component::RootDir).join(path)
    };

    if cfg!(windows) {
      let mut buf = String::new();
      for component in path.components() {
        match component {
          Component::RootDir => buf.push('/'),
          Component::CurDir => buf.push_str("./"),
          Component::ParentDir => buf.push_str("../"),
          Component::Prefix(prefix) => buf.push_str(&prefix.as_os_str().to_string_lossy()),
          Component::Normal(s) => {
            buf.push_str(&s.to_string_lossy());
            buf.push('/')
          }
        }
      }

      // remove the last slash
      if buf != "/" {
        buf.pop();
      }

      buf
    } else {
      path.to_string_lossy().to_string()
    }
  }
/// Format a key used to identify a file embedded in `Assets`.
///
/// Output should use unix path separators and have a root directory to mimic
/// server urls.
Format a key used to identify a file embedded in `Assets`.
Output should use unix path separators and have a root directory to mimic
server urls.
Format a key used to identify a file embedded in ` Assets ` . Output should use unix path separators and have a root directory to mimic server urls .
pub fn format_key(path: impl Into<PathBuf>) -> String {
    let path = path.into();
    // add in root to mimic how it is used from a server url
    let path = if path.has_root() {
      path
    } else {
      Path::new(&Component::RootDir).join(path)
    };
    if cfg!(windows) {
      let mut buf = String::new();
      for component in path.components() {
        match component {
          Component::RootDir => buf.push('/'),
          Component::CurDir => buf.push_str("./"),
          Component::ParentDir => buf.push_str("../"),
          Component::Prefix(prefix) => buf.push_str(&prefix.as_os_str().to_string_lossy()),
          Component::Normal(s) => {
            buf.push_str(&s.to_string_lossy());
            buf.push('/')
          }
        }
      }
      // remove the last slash
      if buf != "/" {
        buf.pop();
      }
      buf
    } else {
      path.to_string_lossy().to_string()
    }
  }
pub fn format_key ( path : impl Into < PathBuf > ) -> String { let path = path . into ( ) ; // add in root to mimic how it is used from a server url let path = if path . has_root ( ) { path } else { Path :: new ( & Component :: RootDir ) . join ( path ) } ; if cfg ! ( windows ) { let mut buf = String :: new ( ) ; for component in path . components ( ) { match component { Component :: RootDir => buf . push ( '/' ) , Component :: CurDir => buf . push_str ( " " ) , Component :: ParentDir => buf . push_str ( " " ) , Component :: Prefix ( prefix ) => buf . push_str ( & prefix . as_os_str ( ) . to_string_lossy ( ) ) , Component :: Normal ( s ) => { buf . push_str ( & s . to_string_lossy ( ) ) ; buf . push ( '/' ) } } } // remove the last slash if buf != " " { buf . pop ( ) ; } buf } else { path . to_string_lossy ( ) . to_string ( ) } }
Format a key used to identify a file embedded in `Assets`.
Format a key used to identify a file embedded in ` Assets ` .
path
impl Into<PathBuf>
path
impl Into<PathBuf>