pub fn parse(s: &str) -> ImageRef {
    // tags may be one of:
    // foo (implies registry.hub.docker.com/library/foo:latest)
    // foo:bar (implies registry.hub.docker.com/library/foo:bar)
    // org/foo:bar (implies registry.hub.docker.com/org/foo:bar)

    // per https://stackoverflow.com/a/42116190, some extra rules are needed to
    // disambiguate external registries
    // localhost/foo:bar is allowed (localhost is special)
    // example.com/foo:bar is allowed
    // host/foo:bar is not allowed (conflicts with docker hub)
    // host:443/foo:bar is allowed (':' or '.' make it unambiguous)

    // we don't attempt to actually validate tags otherwise, so invalid
    // characters could slip through

    let parts: Vec<&str> = s.splitn(2, '/').collect();
    let (registry, image_full) = if parts.len() == 2 && is_registry(parts[0]) {
      // some 3rd party registry
      (Some(parts[0].to_string()), parts[1])
    } else {
      // some other image on the default registry; return the original string
      (None, s)
    };

    if let Some(at_pos) = image_full.find('@') {
      // parts length is guaranteed to be at least 1 given an empty string
      let (image, hash) = image_full.split_at(at_pos);

      ImageRef {
        registry,
        image: image.to_string(),
        hash: Some(hash[1..].to_string()),
        tag: None
      }
    } else {
      // parts length is guaranteed to be at least 1 given an empty string
      let parts: Vec<&str> = image_full.splitn(2, ':').collect();
      let image = parts[0].to_string();
      let tag = parts.get(1).map(|p| String::from(*p));

      ImageRef { registry, image, tag, hash: None }
    }
  }
/// Parses an `ImageRef` from a string.
///
/// This is not fallible, however malformed image strings may return
/// unexpected results.
Parses an `ImageRef` from a string.
This is not fallible, however malformed image strings may return
unexpected results.
Parses an ` ImageRef ` from a string . This is not fallible however malformed image strings may return unexpected results .
pub fn parse(s: &str) -> ImageRef {
    // tags may be one of:
    // foo (implies registry.hub.docker.com/library/foo:latest)
    // foo:bar (implies registry.hub.docker.com/library/foo:bar)
    // org/foo:bar (implies registry.hub.docker.com/org/foo:bar)
    // per https://stackoverflow.com/a/42116190, some extra rules are needed to
    // disambiguate external registries
    // localhost/foo:bar is allowed (localhost is special)
    // example.com/foo:bar is allowed
    // host/foo:bar is not allowed (conflicts with docker hub)
    // host:443/foo:bar is allowed (':' or '.' make it unambiguous)
    // we don't attempt to actually validate tags otherwise, so invalid
    // characters could slip through
    let parts: Vec<&str> = s.splitn(2, '/').collect();
    let (registry, image_full) = if parts.len() == 2 && is_registry(parts[0]) {
      // some 3rd party registry
      (Some(parts[0].to_string()), parts[1])
    } else {
      // some other image on the default registry; return the original string
      (None, s)
    };
    if let Some(at_pos) = image_full.find('@') {
      // parts length is guaranteed to be at least 1 given an empty string
      let (image, hash) = image_full.split_at(at_pos);
      ImageRef {
        registry,
        image: image.to_string(),
        hash: Some(hash[1..].to_string()),
        tag: None
      }
    } else {
      // parts length is guaranteed to be at least 1 given an empty string
      let parts: Vec<&str> = image_full.splitn(2, ':').collect();
      let image = parts[0].to_string();
      let tag = parts.get(1).map(|p| String::from(*p));
      ImageRef { registry, image, tag, hash: None }
    }
  }
pub fn parse ( s : & str ) -> ImageRef { // tags may be one of: // foo (implies registry.hub.docker.com/library/foo:latest) // foo:bar (implies registry.hub.docker.com/library/foo:bar) // org/foo:bar (implies registry.hub.docker.com/org/foo:bar) // per https://stackoverflow.com/a/42116190, some extra rules are needed to // disambiguate external registries // localhost/foo:bar is allowed (localhost is special) // example.com/foo:bar is allowed // host/foo:bar is not allowed (conflicts with docker hub) // host:443/foo:bar is allowed (':' or '.' make it unambiguous) // we don't attempt to actually validate tags otherwise, so invalid // characters could slip through let parts : Vec < & str > = s . splitn ( 2 , '/' ) . collect ( ) ; let ( registry , image_full ) = if parts . len ( ) == 2 && is_registry ( parts [ 0 ] ) { // some 3rd party registry ( Some ( parts [ 0 ] . to_string ( ) ) , parts [ 1 ] ) } else { // some other image on the default registry; return the original string ( None , s ) } ; if let Some ( at_pos ) = image_full . find ( '@' ) { // parts length is guaranteed to be at least 1 given an empty string let ( image , hash ) = image_full . split_at ( at_pos ) ; ImageRef { registry , image : image . to_string ( ) , hash : Some ( hash [ 1 .. ] . to_string ( ) ) , tag : None } } else { // parts length is guaranteed to be at least 1 given an empty string let parts : Vec < & str > = image_full . splitn ( 2 , ':' ) . collect ( ) ; let image = parts [ 0 ] . to_string ( ) ; let tag = parts . get ( 1 ) . map ( | p | String :: from ( * p ) ) ; ImageRef { registry , image , tag , hash : None } } }
Parses an `ImageRef` from a string.
Parses an ` ImageRef ` from a string .
s
&str