cobalt-org / liquid-rust

Liquid templating for Rust
docs.rs/liquid
MIT License
473 stars 79 forks source link

Add support for u64 numbers? #532

Open kairoswater-jason opened 9 months ago

kairoswater-jason commented 9 months ago

liquid-rust version: "0.26.4" rust version: rustc 1.75.0 (82e1608df 2023-12-21) OS: Ubuntu 22.04.3 LTS

Does liquid-rust support 64 bit unsigned integers? Should it?

Attempting to populate a template with an Option<u64> results in the following error "Cannot fit number"

Result::unwrap()on anErr` value: Error { inner: InnerError { msg: "Cannot fit number", user_backtrace: [Trace { trace: None, context: [] }], cause: None } }

But when the u64 is changed to u32, the error does not occur.

This error is triggered when calling liquid::to_object(&parameters).unwrap(); with a parameter struct that contains a u64. In this case &parameters is of the TemplateParameters type as defined below.

#[derive(Debug,Serialize,Clone)]
struct Field {
    name : String,
    typename : String,
    size : u8,
    start_index : u16,
    end_index : u16,
    value_override : Option<u64>
}

#[derive(Debug,Serialize,Clone)]
struct Message {
    name : String,
    fields : Vec<Field>,
    msg_type : MsgType,
    fport : u8,
    length : u8
}

#[derive(Serialize)]
struct TemplateParameters {
    name: String,
    all_messages: Vec<Message>,
    downlinks: Vec<Message>,
    uplinks: Vec<Message>
}