/// Rust source code defining the UDF entrypoint and any helper functions.
#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash
)]
#[serde(crate = "conjure_object::serde")]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct RustUdfSource {
    #[builder(into)]
    #[serde(rename = "sourceCode")]
    source_code: String,
}
impl RustUdfSource {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(source_code: impl Into<String>) -> Self {
        Self::builder().source_code(source_code).build()
    }
    /// Rust source code to transpiled into WASM. The source may contain a single function as the entrypoint, or if several
    /// functions appear at the top level, annotate the entrypoint with `#[main]`. Entrypoint must return a scalar value
    /// matching the containing series type.
    /// Parameters must be typed as `f64` for numeric inputs or `String` for categorical inputs.
    ///
    /// Single function example:
    /// ```ignore
    /// fn run(a: f64, b: f64) -> f64 {
    ///   a + b
    /// }
    ///
    /// ```
    ///
    /// Main with helper function:
    /// ```ignore
    /// #[main]
    /// fn run(sample: f64, band_size: f64) -> f64 {
    ///   excedance_count(sample, band_size)
    /// }
    ///
    /// fn excedance_count(value: f64, band_size: f64) -> f64 {
    ///   let mut excedances = 0.0;
    ///   for i in 1..=5 {
    ///     if value > band_size * i as f64 {
    ///       excedances += 1.0;
    ///     }
    ///   }
    ///   excedances
    /// }
    /// ```
    #[inline]
    pub fn source_code(&self) -> &str {
        &*self.source_code
    }
}
