1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use fluvio_protocol::{Encoder, Decoder};

/// Error during processing SmartModule transform error
//
// The presence of one of these errors most likely indicates a logic bug.
// This error type is `#[repr(i32)]` because these errors are returned
// as the raw return type of a SmartModule WASM function, i.e. the return
// type in `extern "C" fn filter(ptr, len) -> i32`. Positive return values
// indicate the numbers of records, and negative values indicate various
// types of errors.
//
// THEREFORE, THE DISCRIMINANTS FOR ALL VARIANTS ON THIS TYPE MUST BE NEGATIVE
#[repr(i32)]
#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
#[non_exhaustive]
#[fluvio(encode_discriminant)]
pub enum SmartModuleTransformErrorStatus {
    #[error("encountered unknown error during SmartModule processing")]
    #[default]
    UnknownError = -1,
    #[error("failed to decode SmartModule base input")]
    DecodingBaseInput = -11,
    #[error("failed to decode SmartModule record input")]
    DecodingRecords = -22,
    #[error("failed to encode SmartModule output")]
    EncodingOutput = -33,
    #[error("failed to parse SmartModule extra params")]
    ParsingExtraParams = -44,
    #[error("undefined right record in Join SmartModule")]
    UndefinedRightRecord = -55,
}

#[repr(i32)]
#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
#[non_exhaustive]
#[fluvio(encode_discriminant)]
pub enum SmartModuleInitErrorStatus {
    #[error("encountered unknown error during SmartModule processing")]
    #[default]
    UnknownError = -1,
    #[error("Error during initialization")]
    InitError = -2,
    #[error("failed to decode SmartModule init input")]
    DecodingInput = -10,
    #[error("failed to encode SmartModule init output")]
    EncodingOutput = -11,
}

/// Error during processing SmartModule initialization
#[derive(thiserror::Error, Debug)]
pub enum SmartModuleInitError {
    #[error("Missing param {0}")]
    MissingParam(String),
}

#[repr(i32)]
#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq, Encoder, Default, Decoder)]
#[non_exhaustive]
#[fluvio(encode_discriminant)]
pub enum SmartModuleLookbackErrorStatus {
    #[error("encountered unknown error during SmartModule processing")]
    #[default]
    UnknownError = -1,
    #[error("failed to decode SmartModule look_back input")]
    DecodingBaseInput = -66,
    #[error("failed to decode SmartModule look_back record input")]
    DecodingRecords = -77,
    #[error("failed to encode SmartModule look_back output")]
    EncodingOutput = -88,
    #[error("Error returned from user look_back function call")]
    PropagatedError = -99,
}