diff options
| author | Mike Buland <mike@xagasoft.com> | 2025-11-27 12:44:22 -0800 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2025-11-27 12:44:22 -0800 |
| commit | 87b2a5dc9c748976d31061c2fd181a5aa0615799 (patch) | |
| tree | 4646555a09ac7a855352642ad2ca4a4468901616 /rust/src/lib.rs | |
| parent | 654f430ac2da6435c3cbf0014cf0f681211865ee (diff) | |
| download | libgats-87b2a5dc9c748976d31061c2fd181a5aa0615799.tar.gz libgats-87b2a5dc9c748976d31061c2fd181a5aa0615799.tar.bz2 libgats-87b2a5dc9c748976d31061c2fd181a5aa0615799.tar.xz libgats-87b2a5dc9c748976d31061c2fd181a5aa0615799.zip | |
Diffstat (limited to '')
| -rw-r--r-- | rust/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs index a96454e..213fa39 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs | |||
| @@ -243,6 +243,17 @@ impl Value { | |||
| 243 | } | 243 | } |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | pub fn as_int( &self ) -> Result<i64,Error> { | ||
| 247 | if let Value::Integer(i) = self { | ||
| 248 | Ok(*i) | ||
| 249 | } else { | ||
| 250 | Err(Error::new( | ||
| 251 | ErrorKind::InvalidData, | ||
| 252 | "as_int called on non Integer value.", | ||
| 253 | )) | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 246 | pub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error> { | 257 | pub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error> { |
| 247 | match self { | 258 | match self { |
| 248 | Self::Integer(x) => { | 259 | Self::Integer(x) => { |
