rustyphoenixlecture 1.7.0

This project aims to provide a simple a powerfull lecture compilation to generate html web sites
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

///Function which get a full container url with a digest and returns only the url without the digest
/// # Parameters
/// - `full_digest_container` : full container url with a digest
/// # Returns
/// url without the digest
pub fn phoenix_get_apptainer_url(full_digest_container: &String) -> String{
	if full_digest_container.contains("@sha256:") {
		let vec_url: Vec<&str> = full_digest_container.split('@').collect();
		match vec_url.first() {
			Some(url) => String::from(format!("docker://{}", *url)),
			None => panic!("phoenix_get_apptainer_url : impossible")
		}
	}else{
		return String::from(format!("docker://{}", full_digest_container));
	}
}

///Get the apptainer sif image name from full url with digest
/// # Parameters
/// - `full_digest_container` : full container url with a digest
/// # Returns
/// Corresponding sif file name
pub fn phoenix_get_apptainer_sif(full_digest_container: &String) -> String{
	let apptainer_url: String = phoenix_get_apptainer_url(full_digest_container);
	if full_digest_container.contains("/") {
		let vec_url: Vec<&str> = apptainer_url.split('/').collect();
		match vec_url.last() {
			Some(url) => String::from(format!("{}.sif", url.replace(":", "_"))),
			None => panic!("phoenix_get_apptainer_sif : impossible")
		}
	}else{
		return String::from(format!("{}.sif", apptainer_url.replace(":", "_")));
	}
}

#[cfg(test)]
mod tests{
	use super::*;
	
	///Test the phoenix_get_apptainer_url
	#[test]
	fn test_phoenix_get_apptainer_url(){
		assert_eq!(phoenix_get_apptainer_url(&String::from("gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2@sha256:cc8a657107c3d6bb9ea30de7471962966cc9f57cd3fecb64533760ee2fca4e91")), String::from("docker://gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2"));
		
		assert_eq!(phoenix_get_apptainer_url(&String::from("gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2")), String::from("docker://gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2"));
	}
	///Test the phoenix_get_apptainer_sif
	#[test]
	fn test_phoenix_get_apptainer_sif(){
		assert_eq!(phoenix_get_apptainer_sif(&String::from("gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2@sha256:cc8a657107c3d6bb9ea30de7471962966cc9f57cd3fecb64533760ee2fca4e91")), String::from("performancewithstencil_cpu_interactive_code_server_1.0.2.sif"));
		
		assert_eq!(phoenix_get_apptainer_sif(&String::from("gitlab-registry.in2p3.fr/cta-lapp/cours/performancewithstencil/performancewithstencil_cpu_interactive_code_server:1.0.2")), String::from("performancewithstencil_cpu_interactive_code_server_1.0.2.sif"));
	}
}