/// Validate custom_spu requests (one at a time)
Validate custom_spu requests (one at a time)
Validate custom_spu requests ( one at a time )
fn validate_custom_spu_request(
    custom_spu_req: &FlvCreateCustomSpuRequest,
    metadata: &LocalStores,
) -> Result<(), FlvResponseMessage> {
    let spu_id = &custom_spu_req.id;
    let spu_name = &custom_spu_req.name;
    debug!("validating custom-spu: {}({})", spu_name, spu_id);
    // look-up SPU by name or id to check if already exists
    if metadata.spus().spu(spu_name).is_some() || metadata.spus().get_by_id(spu_id).is_some() {
        Err(FlvResponseMessage::new(
            spu_name.clone(),
            FlvErrorCode::SpuAlreadyExists,
            Some(format!("spu '{}({})' already defined", spu_name, spu_id)),
        ))
    } else {
        Ok(())
    }
}
fn validate_custom_spu_request ( custom_spu_req : & FlvCreateCustomSpuRequest , metadata : & LocalStores , ) -> Result < ( ) , FlvResponseMessage > { let spu_id = & custom_spu_req . id ; let spu_name = & custom_spu_req . name ; debug ! ( " " spu_name spu_id ) ; // look-up SPU by name or id to check if already exists if metadata . spus ( ) . spu ( spu_name ) . is_some ( ) || metadata . spus ( ) . get_by_id ( spu_id ) . is_some ( ) { Err ( FlvResponseMessage :: new ( spu_name . clone ( ) , FlvErrorCode :: SpuAlreadyExists , Some ( format ! ( " " spu_name spu_id ) ) , ) ) } else { Ok ( ( ) ) } }
Validate custom_spu requests (one at a time)
Validate custom_spu requests ( one at a time )
custom_spu_req
&FlvCreateCustomSpuRequest
metadata
&LocalStores