Skip to content

Types

Field Manual Section 5 - Payload Specs

Tank brings a full type arsenal to the field. The Entity derive macro identifies the type you're using by inspecting its final path segment (the "trailer"). For example, std::collections::VecDeque, collections::VecDeque, or simply VecDeque all resolve to the same list type.

Tank maps ordinary Rust types (numbers, strings, times, collections) to the closest column types each driver supports, falling back to generic representations when appropriate. Below is the standard mapping of Rust types to each driver's column type. :x: indicates no native support at this time. Collection types may be emulated in some drivers using generic JSON/text representations.

Column Types

RustPostgresSQLiteMySQL/MariaDBDuckDBMongoDBScyllaDB/CassandraValkey/Redis
boolBOOLEANINTEGERBOOLEANBOOLEANBooleanBOOLEANString
i8SMALLINTINTEGERTINYINTTINYINTInt32TINYINTString
i16SMALLINTINTEGERSMALLINTSMALLINTInt32SMALLINTString
i32INTEGERINTEGERINTEGERINTEGERInt32INTString
i64BIGINTINTEGERBIGINTBIGINTInt64BIGINTString
i128NUMERIC(39)NUMERIC(39)HUGEINTVARINTString
u8SMALLINTINTEGERTINYINT UNSIGNEDUTINYINTInt32SMALLINTString
u16INTEGERINTEGERSMALLINT UNSIGNEDUSMALLINTInt32INTString
u32BIGINTINTEGERINTEGER UNSIGNEDUINTEGERInt64BIGINTString
u64NUMERIC(19)INTEGERBIGINT UNSIGNEDUBIGINTInt64VARINTString
u128NUMERIC(39)NUMERIC(39) UNSIGNEDUHUGEINTVARINTString
isizeBIGINTINTEGERBIGINTBIGINTInt64BIGINTString
usizeNUMERIC(19)INTEGERBIGINT UNSIGNEDUBIGINTInt64VARINTString
f32REALREALFLOATFLOATDoubleFLOATString
f64DOUBLEREALDOUBLEDOUBLEDoubleDOUBLEString
rust_decimal::DecimalNUMERICREALDECIMALDECIMALDoubleDECIMALString
tank::FixedDecimal<W,S>NUMERIC(W,S)REALDECIMAL(W,S)DECIMAL(W,S)DoubleDECIMALString
charCHAR(1)TEXTCHAR(1)CHAR(1)StringASCIIString
StringTEXTTEXTTEXT, VARCHAR(60) if pkTEXTStringTEXTString
Box<[u8]>BYTEABLOBBLOBBLOBBinaryBLOBString
time::DateDATETEXT ⚠️DATEDATEDateDATEString
time::TimeTIMETEXT ⚠️TIME(6)TIMEString ⚠️TIMEString
time::PrimitiveDateTimeTIMESTAMPTEXT ⚠️DATETIMETIMESTAMPDateTimeTIMESTAMPString
time::OffsetDateTimeTIMESTAMPTZTEXT ⚠️DATETIMETIMESTAMPTZDateTimeTIMESTAMPString
std::time::DurationINTERVALTIME(6)INTERVALDURATIONString
time::DurationINTERVALTIME(6)INTERVALDURATIONString
tank::IntervalINTERVALTIME(6)INTERVALDURATIONString
uuid::UuidUUIDTEXTCHAR(36)UUIDUuidUUIDString
[T; N]T[N]JSON ⚠️T[N]ArrayVECTOR<T,N>List
VecDeque<T>T[]JSON ⚠️T[]ArrayLIST<T>List
LinkedList<T>T[]JSON ⚠️T[]ArrayLIST<T>List
Vec<T>T[]JSON ⚠️T[]ArrayLIST<T>List
HashMap<K,V>JSON ⚠️MAP(K,V)DocumentMAP<K,V>Hash
BTreeMap<K,V>JSON ⚠️MAP(K,V)DocumentMAP<K,V>Hash

WARNING

When a type falls back to a generic representation (e.g. TEXT or JSON), Tank encodes it predictably so equality and ordering comparisons (where meaningful) behave as expected. Advanced indexing or operator support may vary by driver.

The special isize/usize types map to the native pointer-width integer (64‑bit on 64‑bit targets, 32‑bit on 32‑bit targets). For cross‑database portability prefer explicit i64/u64 unless you truly need platform width.

Wrapper Types

Built‑in wrappers you can use directly in entities. SQL type is inferred from the inner type.

Supported wrappers:

  • tank::Passive<T>: Omit on update or allow default generation on insert.
  • Option<T>: Nullable column.
  • Box<T>
  • Cell<T>
  • RefCell<T>
  • RwLock<T>
  • Arc<T>
  • Rc<T>

With this arsenal, your entities hit every target, every time.

Released under the Apache-2.0 license.