prefix_escape_for_ref

Function prefix_escape_for_ref 

Source
pub fn prefix_escape_for_ref(prefix: &str, s: &str) -> Result<String>
Expand description

Compute a string suitable for use as an OSTree ref, where s can be a (nearly) arbitrary UTF-8 string. This requires a non-empty prefix.

The restrictions on s are:

  • The empty string is not supported
  • There may not be embedded NUL (\0) characters.

The intention behind requiring a prefix is that a common need is to use e.g. [ostree::Repo::list_refs] to find refs of a certain “type”.

§Examples:

use ostree_ext::refescape;
let s = "registry:quay.io/coreos/fedora:latest";
assert_eq!(refescape::prefix_escape_for_ref("container", s)?,
           "container/registry_3A_quay_2E_io/coreos/fedora_3A_latest");