msg += std::string(yaml);
msg += "# Validation result: ";
try {
- pdns::rust::settings::rec::validate_forward_zones("forward_zones", forwards);
+ pdns::rust::settings::rec::validate_forward_zones("forward_zones", {forwards.data(), forwards.size()});
msg += "OK";
}
catch (const rust::Error& err) {
return msg;
}
-static std::string showAllowYAML(const ::rust::String& rfilename, const string& section, const string& key, const std::function<void(const ::rust::String&, const ::rust::Vec<::rust::String>&)>& func)
+static std::string showAllowYAML(const ::rust::String& rfilename, const string& section, const string& key, const std::function<void(const ::rust::String&, ::rust::Slice<::rust::String const>)>& func)
{
std::string msg;
if (rfilename.empty() || boost::ends_with(rfilename, ".yml")) {
msg += std::string(yaml);
msg += "# Validation result: ";
try {
- func(key, allows);
+ func(key, {allows.data(), allows.size()});
msg += "OK";
}
catch (const rust::Error& err) {
}
auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_allow_from(data);
- pdns::rust::settings::rec::validate_allow_from(filename, yamlvec);
+ pdns::rust::settings::rec::validate_allow_from(filename, {yamlvec.data(), yamlvec.size()});
vec = yamlvec;
}
}
auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_forward_zones(data);
- pdns::rust::settings::rec::validate_forward_zones("forward_zones", yamlvec);
+ pdns::rust::settings::rec::validate_forward_zones("forward_zones", {yamlvec.data(), yamlvec.size()});
vec = yamlvec;
}
}
auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_allow_notify_for(data);
- pdns::rust::settings::rec::validate_allow_notify_for("allow-notify-for", yamlvec);
+ pdns::rust::settings::rec::validate_allow_notify_for("allow-notify-for", {yamlvec.data(), yamlvec.size()});
vec = yamlvec;
}
fn validate(self: &ApiZones, field: &str) -> Result<()>;
// Helper functions to call the proper validate function on vectors of various kinds
- fn validate_auth_zones(field: &str, vec: &Vec<AuthZone>) -> Result<()>;
- fn validate_forward_zones(field: &str, vec: &Vec<ForwardZone>) -> Result<()>;
- fn validate_allow_for(field: &str, vec: &Vec<String>) -> Result<()>;
- fn validate_allow_notify_for(field: &str, vec: &Vec<String>) -> Result<()>;
- fn validate_allow_from(field: &str, vec: &Vec<String>) -> Result<()>;
+ fn validate_auth_zones(field: &str, vec: &[AuthZone]) -> Result<()>;
+ fn validate_forward_zones(field: &str, vec: &[ForwardZone]) -> Result<()>;
+ fn validate_allow_for(field: &str, vec: &[String]) -> Result<()>;
+ fn validate_allow_notify_for(field: &str, vec: &[String]) -> Result<()>;
+ fn validate_allow_from(field: &str, vec: &[String]) -> Result<()>;
// The functions to maintain REST API managed zones
fn api_read_zones(path: &str) -> Result<UniquePtr<ApiZones>>;
}
}
-pub fn validate_auth_zones(field: &str, vec: &Vec<AuthZone>) -> Result<(), ValidationError> {
+pub fn validate_auth_zones(field: &str, vec: &[AuthZone]) -> Result<(), ValidationError> {
validate_vec(field, vec, |field, element| element.validate(field))
}
pub fn validate_forward_zones(
field: &str,
- vec: &Vec<ForwardZone>,
+ vec: &[ForwardZone],
) -> Result<(), ValidationError> {
validate_vec(field, vec, |field, element| element.validate(field))
}
serde_yaml::to_string(&outerval)
}
-pub fn validate_allow_from(field: &str, vec: &Vec<String>) -> Result<(), ValidationError> {
+pub fn validate_allow_from(field: &str, vec: &[String]) -> Result<(), ValidationError> {
validate_vec(field, vec, validate_subnet)
}
allow_from_to_yaml_string(vec)
}
-pub fn validate_allow_for(field: &str, vec: &Vec<String>) -> Result<(), ValidationError> {
+pub fn validate_allow_for(field: &str, vec: &[String]) -> Result<(), ValidationError> {
validate_vec(field, vec, validate_name)
}
-pub fn validate_allow_notify_for(field: &str, vec: &Vec<String>) -> Result<(), ValidationError> {
+pub fn validate_allow_notify_for(field: &str, vec: &[String]) -> Result<(), ValidationError> {
validate_vec(field, vec, validate_name)
}
}
try {
- ::pdns::rust::settings::rec::validate_allow_from(aclType, vec);
+ ::pdns::rust::settings::rec::validate_allow_from(aclType, {vec.data(), vec.size()});
}
catch (const ::rust::Error& e) {
throw ApiException(string("Unable to convert: ") + e.what());