spin_world/
conversions.rs

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
use super::*;

mod rdbms_types {
    use super::*;

    impl From<v2::rdbms_types::Column> for v1::rdbms_types::Column {
        fn from(value: v2::rdbms_types::Column) -> Self {
            v1::rdbms_types::Column {
                name: value.name,
                data_type: value.data_type.into(),
            }
        }
    }

    impl From<spin::postgres::postgres::Column> for v1::rdbms_types::Column {
        fn from(value: spin::postgres::postgres::Column) -> Self {
            v1::rdbms_types::Column {
                name: value.name,
                data_type: value.data_type.into(),
            }
        }
    }

    impl From<spin::postgres::postgres::Column> for v2::rdbms_types::Column {
        fn from(value: spin::postgres::postgres::Column) -> Self {
            v2::rdbms_types::Column {
                name: value.name,
                data_type: value.data_type.into(),
            }
        }
    }

    impl From<v2::rdbms_types::DbValue> for v1::rdbms_types::DbValue {
        fn from(value: v2::rdbms_types::DbValue) -> v1::rdbms_types::DbValue {
            match value {
                v2::rdbms_types::DbValue::Boolean(b) => v1::rdbms_types::DbValue::Boolean(b),
                v2::rdbms_types::DbValue::Int8(i) => v1::rdbms_types::DbValue::Int8(i),
                v2::rdbms_types::DbValue::Int16(i) => v1::rdbms_types::DbValue::Int16(i),
                v2::rdbms_types::DbValue::Int32(i) => v1::rdbms_types::DbValue::Int32(i),
                v2::rdbms_types::DbValue::Int64(i) => v1::rdbms_types::DbValue::Int64(i),
                v2::rdbms_types::DbValue::Uint8(j) => v1::rdbms_types::DbValue::Uint8(j),
                v2::rdbms_types::DbValue::Uint16(u) => v1::rdbms_types::DbValue::Uint16(u),
                v2::rdbms_types::DbValue::Uint32(u) => v1::rdbms_types::DbValue::Uint32(u),
                v2::rdbms_types::DbValue::Uint64(u) => v1::rdbms_types::DbValue::Uint64(u),
                v2::rdbms_types::DbValue::Floating32(r) => v1::rdbms_types::DbValue::Floating32(r),
                v2::rdbms_types::DbValue::Floating64(r) => v1::rdbms_types::DbValue::Floating64(r),
                v2::rdbms_types::DbValue::Str(s) => v1::rdbms_types::DbValue::Str(s),
                v2::rdbms_types::DbValue::Binary(b) => v1::rdbms_types::DbValue::Binary(b),
                v2::rdbms_types::DbValue::DbNull => v1::rdbms_types::DbValue::DbNull,
                v2::rdbms_types::DbValue::Unsupported => v1::rdbms_types::DbValue::Unsupported,
            }
        }
    }

    impl From<spin::postgres::postgres::DbValue> for v1::rdbms_types::DbValue {
        fn from(value: spin::postgres::postgres::DbValue) -> v1::rdbms_types::DbValue {
            match value {
                spin::postgres::postgres::DbValue::Boolean(b) => {
                    v1::rdbms_types::DbValue::Boolean(b)
                }
                spin::postgres::postgres::DbValue::Int8(i) => v1::rdbms_types::DbValue::Int8(i),
                spin::postgres::postgres::DbValue::Int16(i) => v1::rdbms_types::DbValue::Int16(i),
                spin::postgres::postgres::DbValue::Int32(i) => v1::rdbms_types::DbValue::Int32(i),
                spin::postgres::postgres::DbValue::Int64(i) => v1::rdbms_types::DbValue::Int64(i),
                spin::postgres::postgres::DbValue::Floating32(r) => {
                    v1::rdbms_types::DbValue::Floating32(r)
                }
                spin::postgres::postgres::DbValue::Floating64(r) => {
                    v1::rdbms_types::DbValue::Floating64(r)
                }
                spin::postgres::postgres::DbValue::Str(s) => v1::rdbms_types::DbValue::Str(s),
                spin::postgres::postgres::DbValue::Binary(b) => v1::rdbms_types::DbValue::Binary(b),
                spin::postgres::postgres::DbValue::DbNull => v1::rdbms_types::DbValue::DbNull,
                spin::postgres::postgres::DbValue::Unsupported => {
                    v1::rdbms_types::DbValue::Unsupported
                }
                _ => v1::rdbms_types::DbValue::Unsupported,
            }
        }
    }

    impl From<spin::postgres::postgres::DbValue> for v2::rdbms_types::DbValue {
        fn from(value: spin::postgres::postgres::DbValue) -> v2::rdbms_types::DbValue {
            match value {
                spin::postgres::postgres::DbValue::Boolean(b) => {
                    v2::rdbms_types::DbValue::Boolean(b)
                }
                spin::postgres::postgres::DbValue::Int8(i) => v2::rdbms_types::DbValue::Int8(i),
                spin::postgres::postgres::DbValue::Int16(i) => v2::rdbms_types::DbValue::Int16(i),
                spin::postgres::postgres::DbValue::Int32(i) => v2::rdbms_types::DbValue::Int32(i),
                spin::postgres::postgres::DbValue::Int64(i) => v2::rdbms_types::DbValue::Int64(i),
                spin::postgres::postgres::DbValue::Floating32(r) => {
                    v2::rdbms_types::DbValue::Floating32(r)
                }
                spin::postgres::postgres::DbValue::Floating64(r) => {
                    v2::rdbms_types::DbValue::Floating64(r)
                }
                spin::postgres::postgres::DbValue::Str(s) => v2::rdbms_types::DbValue::Str(s),
                spin::postgres::postgres::DbValue::Binary(b) => v2::rdbms_types::DbValue::Binary(b),
                spin::postgres::postgres::DbValue::DbNull => v2::rdbms_types::DbValue::DbNull,
                spin::postgres::postgres::DbValue::Unsupported => {
                    v2::rdbms_types::DbValue::Unsupported
                }
                _ => v2::rdbms_types::DbValue::Unsupported,
            }
        }
    }

    impl From<spin::postgres::postgres::DbDataType> for v1::rdbms_types::DbDataType {
        fn from(value: spin::postgres::postgres::DbDataType) -> v1::rdbms_types::DbDataType {
            match value {
                spin::postgres::postgres::DbDataType::Boolean => {
                    v1::rdbms_types::DbDataType::Boolean
                }
                spin::postgres::postgres::DbDataType::Int8 => v1::rdbms_types::DbDataType::Int8,
                spin::postgres::postgres::DbDataType::Int16 => v1::rdbms_types::DbDataType::Int16,
                spin::postgres::postgres::DbDataType::Int32 => v1::rdbms_types::DbDataType::Int32,
                spin::postgres::postgres::DbDataType::Int64 => v1::rdbms_types::DbDataType::Int64,
                spin::postgres::postgres::DbDataType::Floating32 => {
                    v1::rdbms_types::DbDataType::Floating32
                }
                spin::postgres::postgres::DbDataType::Floating64 => {
                    v1::rdbms_types::DbDataType::Floating64
                }
                spin::postgres::postgres::DbDataType::Str => v1::rdbms_types::DbDataType::Str,
                spin::postgres::postgres::DbDataType::Binary => v1::rdbms_types::DbDataType::Binary,
                spin::postgres::postgres::DbDataType::Other => v1::rdbms_types::DbDataType::Other,
                _ => v1::rdbms_types::DbDataType::Other,
            }
        }
    }

    impl From<spin::postgres::postgres::DbDataType> for v2::rdbms_types::DbDataType {
        fn from(value: spin::postgres::postgres::DbDataType) -> v2::rdbms_types::DbDataType {
            match value {
                spin::postgres::postgres::DbDataType::Boolean => {
                    v2::rdbms_types::DbDataType::Boolean
                }
                spin::postgres::postgres::DbDataType::Int8 => v2::rdbms_types::DbDataType::Int8,
                spin::postgres::postgres::DbDataType::Int16 => v2::rdbms_types::DbDataType::Int16,
                spin::postgres::postgres::DbDataType::Int32 => v2::rdbms_types::DbDataType::Int32,
                spin::postgres::postgres::DbDataType::Int64 => v2::rdbms_types::DbDataType::Int64,
                spin::postgres::postgres::DbDataType::Floating32 => {
                    v2::rdbms_types::DbDataType::Floating32
                }
                spin::postgres::postgres::DbDataType::Floating64 => {
                    v2::rdbms_types::DbDataType::Floating64
                }
                spin::postgres::postgres::DbDataType::Str => v2::rdbms_types::DbDataType::Str,
                spin::postgres::postgres::DbDataType::Binary => v2::rdbms_types::DbDataType::Binary,
                spin::postgres::postgres::DbDataType::Other => v2::rdbms_types::DbDataType::Other,
                _ => v2::rdbms_types::DbDataType::Other,
            }
        }
    }

    impl From<v2::rdbms_types::DbDataType> for v1::rdbms_types::DbDataType {
        fn from(value: v2::rdbms_types::DbDataType) -> v1::rdbms_types::DbDataType {
            match value {
                v2::rdbms_types::DbDataType::Boolean => v1::rdbms_types::DbDataType::Boolean,
                v2::rdbms_types::DbDataType::Int8 => v1::rdbms_types::DbDataType::Int8,
                v2::rdbms_types::DbDataType::Int16 => v1::rdbms_types::DbDataType::Int16,
                v2::rdbms_types::DbDataType::Int32 => v1::rdbms_types::DbDataType::Int32,
                v2::rdbms_types::DbDataType::Int64 => v1::rdbms_types::DbDataType::Int64,
                v2::rdbms_types::DbDataType::Uint8 => v1::rdbms_types::DbDataType::Uint8,
                v2::rdbms_types::DbDataType::Uint16 => v1::rdbms_types::DbDataType::Uint16,
                v2::rdbms_types::DbDataType::Uint32 => v1::rdbms_types::DbDataType::Uint32,
                v2::rdbms_types::DbDataType::Uint64 => v1::rdbms_types::DbDataType::Uint64,
                v2::rdbms_types::DbDataType::Floating32 => v1::rdbms_types::DbDataType::Floating32,
                v2::rdbms_types::DbDataType::Floating64 => v1::rdbms_types::DbDataType::Floating64,
                v2::rdbms_types::DbDataType::Str => v1::rdbms_types::DbDataType::Str,
                v2::rdbms_types::DbDataType::Binary => v1::rdbms_types::DbDataType::Binary,
                v2::rdbms_types::DbDataType::Other => v1::rdbms_types::DbDataType::Other,
            }
        }
    }

    impl From<v1::rdbms_types::ParameterValue> for v2::rdbms_types::ParameterValue {
        fn from(value: v1::rdbms_types::ParameterValue) -> v2::rdbms_types::ParameterValue {
            match value {
                v1::rdbms_types::ParameterValue::Boolean(b) => {
                    v2::rdbms_types::ParameterValue::Boolean(b)
                }
                v1::rdbms_types::ParameterValue::Int8(i) => {
                    v2::rdbms_types::ParameterValue::Int8(i)
                }
                v1::rdbms_types::ParameterValue::Int16(i) => {
                    v2::rdbms_types::ParameterValue::Int16(i)
                }
                v1::rdbms_types::ParameterValue::Int32(i) => {
                    v2::rdbms_types::ParameterValue::Int32(i)
                }
                v1::rdbms_types::ParameterValue::Int64(i) => {
                    v2::rdbms_types::ParameterValue::Int64(i)
                }
                v1::rdbms_types::ParameterValue::Uint8(u) => {
                    v2::rdbms_types::ParameterValue::Uint8(u)
                }
                v1::rdbms_types::ParameterValue::Uint16(u) => {
                    v2::rdbms_types::ParameterValue::Uint16(u)
                }
                v1::rdbms_types::ParameterValue::Uint32(u) => {
                    v2::rdbms_types::ParameterValue::Uint32(u)
                }
                v1::rdbms_types::ParameterValue::Uint64(u) => {
                    v2::rdbms_types::ParameterValue::Uint64(u)
                }
                v1::rdbms_types::ParameterValue::Floating32(r) => {
                    v2::rdbms_types::ParameterValue::Floating32(r)
                }
                v1::rdbms_types::ParameterValue::Floating64(r) => {
                    v2::rdbms_types::ParameterValue::Floating64(r)
                }
                v1::rdbms_types::ParameterValue::Str(s) => v2::rdbms_types::ParameterValue::Str(s),
                v1::rdbms_types::ParameterValue::Binary(b) => {
                    v2::rdbms_types::ParameterValue::Binary(b)
                }
                v1::rdbms_types::ParameterValue::DbNull => v2::rdbms_types::ParameterValue::DbNull,
            }
        }
    }

    impl TryFrom<v1::rdbms_types::ParameterValue> for spin::postgres::postgres::ParameterValue {
        type Error = v1::postgres::PgError;

        fn try_from(
            value: v1::rdbms_types::ParameterValue,
        ) -> Result<spin::postgres::postgres::ParameterValue, Self::Error> {
            let converted = match value {
                v1::rdbms_types::ParameterValue::Boolean(b) => {
                    spin::postgres::postgres::ParameterValue::Boolean(b)
                }
                v1::rdbms_types::ParameterValue::Int8(i) => {
                    spin::postgres::postgres::ParameterValue::Int8(i)
                }
                v1::rdbms_types::ParameterValue::Int16(i) => {
                    spin::postgres::postgres::ParameterValue::Int16(i)
                }
                v1::rdbms_types::ParameterValue::Int32(i) => {
                    spin::postgres::postgres::ParameterValue::Int32(i)
                }
                v1::rdbms_types::ParameterValue::Int64(i) => {
                    spin::postgres::postgres::ParameterValue::Int64(i)
                }
                v1::rdbms_types::ParameterValue::Uint8(_)
                | v1::rdbms_types::ParameterValue::Uint16(_)
                | v1::rdbms_types::ParameterValue::Uint32(_)
                | v1::rdbms_types::ParameterValue::Uint64(_) => {
                    return Err(v1::postgres::PgError::ValueConversionFailed(
                        "Postgres does not support unsigned integers".to_owned(),
                    ));
                }
                v1::rdbms_types::ParameterValue::Floating32(r) => {
                    spin::postgres::postgres::ParameterValue::Floating32(r)
                }
                v1::rdbms_types::ParameterValue::Floating64(r) => {
                    spin::postgres::postgres::ParameterValue::Floating64(r)
                }
                v1::rdbms_types::ParameterValue::Str(s) => {
                    spin::postgres::postgres::ParameterValue::Str(s)
                }
                v1::rdbms_types::ParameterValue::Binary(b) => {
                    spin::postgres::postgres::ParameterValue::Binary(b)
                }
                v1::rdbms_types::ParameterValue::DbNull => {
                    spin::postgres::postgres::ParameterValue::DbNull
                }
            };
            Ok(converted)
        }
    }

    impl TryFrom<v2::rdbms_types::ParameterValue> for spin::postgres::postgres::ParameterValue {
        type Error = v2::rdbms_types::Error;

        fn try_from(
            value: v2::rdbms_types::ParameterValue,
        ) -> Result<spin::postgres::postgres::ParameterValue, Self::Error> {
            let converted = match value {
                v2::rdbms_types::ParameterValue::Boolean(b) => {
                    spin::postgres::postgres::ParameterValue::Boolean(b)
                }
                v2::rdbms_types::ParameterValue::Int8(i) => {
                    spin::postgres::postgres::ParameterValue::Int8(i)
                }
                v2::rdbms_types::ParameterValue::Int16(i) => {
                    spin::postgres::postgres::ParameterValue::Int16(i)
                }
                v2::rdbms_types::ParameterValue::Int32(i) => {
                    spin::postgres::postgres::ParameterValue::Int32(i)
                }
                v2::rdbms_types::ParameterValue::Int64(i) => {
                    spin::postgres::postgres::ParameterValue::Int64(i)
                }
                v2::rdbms_types::ParameterValue::Uint8(_)
                | v2::rdbms_types::ParameterValue::Uint16(_)
                | v2::rdbms_types::ParameterValue::Uint32(_)
                | v2::rdbms_types::ParameterValue::Uint64(_) => {
                    return Err(v2::rdbms_types::Error::ValueConversionFailed(
                        "Postgres does not support unsigned integers".to_owned(),
                    ));
                }
                v2::rdbms_types::ParameterValue::Floating32(r) => {
                    spin::postgres::postgres::ParameterValue::Floating32(r)
                }
                v2::rdbms_types::ParameterValue::Floating64(r) => {
                    spin::postgres::postgres::ParameterValue::Floating64(r)
                }
                v2::rdbms_types::ParameterValue::Str(s) => {
                    spin::postgres::postgres::ParameterValue::Str(s)
                }
                v2::rdbms_types::ParameterValue::Binary(b) => {
                    spin::postgres::postgres::ParameterValue::Binary(b)
                }
                v2::rdbms_types::ParameterValue::DbNull => {
                    spin::postgres::postgres::ParameterValue::DbNull
                }
            };
            Ok(converted)
        }
    }

    impl From<v2::rdbms_types::Error> for v1::mysql::MysqlError {
        fn from(error: v2::rdbms_types::Error) -> v1::mysql::MysqlError {
            match error {
                v2::mysql::Error::ConnectionFailed(e) => v1::mysql::MysqlError::ConnectionFailed(e),
                v2::mysql::Error::BadParameter(e) => v1::mysql::MysqlError::BadParameter(e),
                v2::mysql::Error::QueryFailed(e) => v1::mysql::MysqlError::QueryFailed(e),
                v2::mysql::Error::ValueConversionFailed(e) => {
                    v1::mysql::MysqlError::ValueConversionFailed(e)
                }
                v2::mysql::Error::Other(e) => v1::mysql::MysqlError::OtherError(e),
            }
        }
    }

    impl From<spin::postgres::postgres::Error> for v1::postgres::PgError {
        fn from(error: spin::postgres::postgres::Error) -> v1::postgres::PgError {
            match error {
                spin::postgres::postgres::Error::ConnectionFailed(e) => {
                    v1::postgres::PgError::ConnectionFailed(e)
                }
                spin::postgres::postgres::Error::BadParameter(e) => {
                    v1::postgres::PgError::BadParameter(e)
                }
                spin::postgres::postgres::Error::QueryFailed(e) => {
                    v1::postgres::PgError::QueryFailed(e)
                }
                spin::postgres::postgres::Error::ValueConversionFailed(e) => {
                    v1::postgres::PgError::ValueConversionFailed(e)
                }
                spin::postgres::postgres::Error::Other(e) => v1::postgres::PgError::OtherError(e),
            }
        }
    }

    impl From<spin::postgres::postgres::Error> for v2::rdbms_types::Error {
        fn from(error: spin::postgres::postgres::Error) -> v2::rdbms_types::Error {
            match error {
                spin::postgres::postgres::Error::ConnectionFailed(e) => {
                    v2::rdbms_types::Error::ConnectionFailed(e)
                }
                spin::postgres::postgres::Error::BadParameter(e) => {
                    v2::rdbms_types::Error::BadParameter(e)
                }
                spin::postgres::postgres::Error::QueryFailed(e) => {
                    v2::rdbms_types::Error::QueryFailed(e)
                }
                spin::postgres::postgres::Error::ValueConversionFailed(e) => {
                    v2::rdbms_types::Error::ValueConversionFailed(e)
                }
                spin::postgres::postgres::Error::Other(e) => v2::rdbms_types::Error::Other(e),
            }
        }
    }
}

mod postgres {
    use super::*;

    impl From<spin::postgres::postgres::RowSet> for v1::postgres::RowSet {
        fn from(value: spin::postgres::postgres::RowSet) -> v1::postgres::RowSet {
            v1::mysql::RowSet {
                columns: value.columns.into_iter().map(Into::into).collect(),
                rows: value
                    .rows
                    .into_iter()
                    .map(|r| r.into_iter().map(Into::into).collect())
                    .collect(),
            }
        }
    }

    impl From<spin::postgres::postgres::RowSet> for v2::rdbms_types::RowSet {
        fn from(value: spin::postgres::postgres::RowSet) -> v2::rdbms_types::RowSet {
            v2::rdbms_types::RowSet {
                columns: value.columns.into_iter().map(Into::into).collect(),
                rows: value
                    .rows
                    .into_iter()
                    .map(|r| r.into_iter().map(Into::into).collect())
                    .collect(),
            }
        }
    }
}

mod mysql {
    use super::*;
    impl From<v2::mysql::RowSet> for v1::mysql::RowSet {
        fn from(value: v2::mysql::RowSet) -> v1::mysql::RowSet {
            v1::mysql::RowSet {
                columns: value.columns.into_iter().map(Into::into).collect(),
                rows: value
                    .rows
                    .into_iter()
                    .map(|r| r.into_iter().map(Into::into).collect())
                    .collect(),
            }
        }
    }
}

mod redis {
    use super::*;

    impl From<v1::redis::RedisParameter> for v2::redis::RedisParameter {
        fn from(value: v1::redis::RedisParameter) -> Self {
            match value {
                v1::redis::RedisParameter::Int64(i) => v2::redis::RedisParameter::Int64(i),
                v1::redis::RedisParameter::Binary(b) => v2::redis::RedisParameter::Binary(b),
            }
        }
    }

    impl From<v2::redis::RedisResult> for v1::redis::RedisResult {
        fn from(value: v2::redis::RedisResult) -> Self {
            match value {
                v2::redis::RedisResult::Nil => v1::redis::RedisResult::Nil,
                v2::redis::RedisResult::Status(s) => v1::redis::RedisResult::Status(s),
                v2::redis::RedisResult::Int64(i) => v1::redis::RedisResult::Int64(i),
                v2::redis::RedisResult::Binary(b) => v1::redis::RedisResult::Binary(b),
            }
        }
    }
}

mod llm {
    use super::*;

    impl From<v1::llm::InferencingParams> for v2::llm::InferencingParams {
        fn from(value: v1::llm::InferencingParams) -> Self {
            Self {
                max_tokens: value.max_tokens,
                repeat_penalty: value.repeat_penalty,
                repeat_penalty_last_n_token_count: value.repeat_penalty_last_n_token_count,
                temperature: value.temperature,
                top_k: value.top_k,
                top_p: value.top_p,
            }
        }
    }

    impl From<v2::llm::InferencingResult> for v1::llm::InferencingResult {
        fn from(value: v2::llm::InferencingResult) -> Self {
            Self {
                text: value.text,
                usage: v1::llm::InferencingUsage {
                    prompt_token_count: value.usage.prompt_token_count,
                    generated_token_count: value.usage.generated_token_count,
                },
            }
        }
    }

    impl From<v2::llm::EmbeddingsResult> for v1::llm::EmbeddingsResult {
        fn from(value: v2::llm::EmbeddingsResult) -> Self {
            Self {
                embeddings: value.embeddings,
                usage: v1::llm::EmbeddingsUsage {
                    prompt_token_count: value.usage.prompt_token_count,
                },
            }
        }
    }

    impl From<v2::llm::Error> for v1::llm::Error {
        fn from(value: v2::llm::Error) -> Self {
            match value {
                v2::llm::Error::ModelNotSupported => Self::ModelNotSupported,
                v2::llm::Error::RuntimeError(s) => Self::RuntimeError(s),
                v2::llm::Error::InvalidInput(s) => Self::InvalidInput(s),
            }
        }
    }
}