Decimal.d.ts (9635B)
1 // generated by diplomat-tool 2 import type { DecimalLimitError } from "./DecimalLimitError" 3 import type { DecimalParseError } from "./DecimalParseError" 4 import type { DecimalRoundingIncrement } from "./DecimalRoundingIncrement" 5 import type { DecimalSign } from "./DecimalSign" 6 import type { DecimalSignDisplay } from "./DecimalSignDisplay" 7 import type { DecimalSignedRoundingMode } from "./DecimalSignedRoundingMode" 8 import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; 9 10 11 /** 12 * See the [Rust documentation for `Decimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html) for more information. 13 */ 14 15 16 export class Decimal { 17 get ffiValue(): pointer; 18 19 20 /** 21 * Construct an [`Decimal`] from an integer. 22 * 23 * See the [Rust documentation for `Decimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.Decimal.html) for more information. 24 */ 25 static fromNumber(v: number): Decimal; 26 27 /** 28 * Construct an [`Decimal`] from an integer. 29 * 30 * See the [Rust documentation for `Decimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.Decimal.html) for more information. 31 */ 32 static fromBigInt(v: bigint): Decimal; 33 34 /** 35 * Construct an [`Decimal`] from an float, with a given power of 10 for the lower magnitude 36 * 37 * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.try_from_f64) for more information. 38 * 39 * See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. 40 */ 41 static fromNumberWithLowerMagnitude(f: number, magnitude: number): Decimal; 42 43 /** 44 * Construct an [`Decimal`] from an float, for a given number of significant digits 45 * 46 * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.try_from_f64) for more information. 47 * 48 * See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. 49 */ 50 static fromNumberWithSignificantDigits(f: number, digits: number): Decimal; 51 52 /** 53 * Construct an [`Decimal`] from an float, with enough digits to recover 54 * the original floating point in IEEE 754 without needing trailing zeros 55 * 56 * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.try_from_f64) for more information. 57 * 58 * See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. 59 */ 60 static fromNumberWithRoundTripPrecision(f: number): Decimal; 61 62 /** 63 * Construct an [`Decimal`] from a string. 64 * 65 * See the [Rust documentation for `try_from_str`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.try_from_str) for more information. 66 */ 67 static fromString(v: string): Decimal; 68 69 /** 70 * See the [Rust documentation for `digit_at`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.digit_at) for more information. 71 */ 72 digitAt(magnitude: number): number; 73 74 /** 75 * See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.magnitude_range) for more information. 76 */ 77 get magnitudeStart(): number; 78 79 /** 80 * See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.magnitude_range) for more information. 81 */ 82 get magnitudeEnd(): number; 83 84 /** 85 * See the [Rust documentation for `nonzero_magnitude_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.nonzero_magnitude_start) for more information. 86 */ 87 get nonzeroMagnitudeStart(): number; 88 89 /** 90 * See the [Rust documentation for `nonzero_magnitude_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.nonzero_magnitude_end) for more information. 91 */ 92 get nonzeroMagnitudeEnd(): number; 93 94 /** 95 * See the [Rust documentation for `is_zero`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.is_zero) for more information. 96 */ 97 get isZero(): boolean; 98 99 /** 100 * Multiply the [`Decimal`] by a given power of ten. 101 * 102 * See the [Rust documentation for `multiply_pow10`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.multiply_pow10) for more information. 103 */ 104 multiplyPow10(power: number): void; 105 106 /** 107 * See the [Rust documentation for `sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.sign) for more information. 108 */ 109 get sign(): DecimalSign; 110 111 /** 112 * Set the sign of the [`Decimal`]. 113 * 114 * See the [Rust documentation for `set_sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.set_sign) for more information. 115 */ 116 set sign(sign: DecimalSign); 117 118 /** 119 * See the [Rust documentation for `apply_sign_display`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.apply_sign_display) for more information. 120 */ 121 applySignDisplay(signDisplay: DecimalSignDisplay): void; 122 123 /** 124 * See the [Rust documentation for `trim_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.trim_start) for more information. 125 */ 126 trimStart(): void; 127 128 /** 129 * See the [Rust documentation for `trim_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.trim_end) for more information. 130 */ 131 trimEnd(): void; 132 133 /** 134 * See the [Rust documentation for `trim_end_if_integer`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.trim_end_if_integer) for more information. 135 */ 136 trimEndIfInteger(): void; 137 138 /** 139 * Zero-pad the [`Decimal`] on the left to a particular position 140 * 141 * See the [Rust documentation for `pad_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.pad_start) for more information. 142 */ 143 padStart(position: number): void; 144 145 /** 146 * Zero-pad the [`Decimal`] on the right to a particular position 147 * 148 * See the [Rust documentation for `pad_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.pad_end) for more information. 149 */ 150 padEnd(position: number): void; 151 152 /** 153 * Truncate the [`Decimal`] on the left to a particular position, deleting digits if necessary. This is useful for, e.g. abbreviating years 154 * ("2022" -> "22") 155 * 156 * See the [Rust documentation for `set_max_position`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.set_max_position) for more information. 157 */ 158 setMaxPosition(position: number): void; 159 160 /** 161 * Round the number at a particular digit position. 162 * 163 * This uses half to even rounding, which resolves ties by selecting the nearest 164 * even integer to the original value. 165 * 166 * See the [Rust documentation for `round`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.round) for more information. 167 */ 168 round(position: number): void; 169 170 /** 171 * See the [Rust documentation for `ceil`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.ceil) for more information. 172 */ 173 ceil(position: number): void; 174 175 /** 176 * See the [Rust documentation for `expand`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.expand) for more information. 177 */ 178 expand(position: number): void; 179 180 /** 181 * See the [Rust documentation for `floor`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.floor) for more information. 182 */ 183 floor(position: number): void; 184 185 /** 186 * See the [Rust documentation for `trunc`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.trunc) for more information. 187 */ 188 trunc(position: number): void; 189 190 /** 191 * See the [Rust documentation for `round_with_mode`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.round_with_mode) for more information. 192 */ 193 roundWithMode(position: number, mode: DecimalSignedRoundingMode): void; 194 195 /** 196 * See the [Rust documentation for `round_with_mode_and_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.round_with_mode_and_increment) for more information. 197 */ 198 roundWithModeAndIncrement(position: number, mode: DecimalSignedRoundingMode, increment: DecimalRoundingIncrement): void; 199 200 /** 201 * Concatenates `other` to the end of `self`. 202 * 203 * If successful, `other` will be set to 0 and a successful status is returned. 204 * 205 * If not successful, `other` will be unchanged and an error is returned. 206 * 207 * See the [Rust documentation for `concatenate_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.concatenate_end) for more information. 208 */ 209 concatenateEnd(other: Decimal): boolean; 210 211 /** 212 * Format the [`Decimal`] as a string. 213 * 214 * See the [Rust documentation for `write_to`](https://docs.rs/fixed_decimal/latest/fixed_decimal/type.Decimal.html#method.write_to) for more information. 215 */ 216 toString(): string; 217 }