xberg 1.3.10 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -4
- data/ext/xberg_rb/native/Cargo.lock +783 -842
- data/ext/xberg_rb/native/Cargo.toml +9 -8
- data/ext/xberg_rb/src/lib.rs +2122 -470
- data/lib/xberg/native.rb +135 -100
- data/lib/xberg/version.rb +2 -2
- data/sig/types.rbs +2343 -27
- metadata +3 -3
data/ext/xberg_rb/src/lib.rs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:52b36849d48efb41822063b25796d07fdb6c9ff245a91d24cade2d5e9cbcea17
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
clippy::useless_conversion,
|
|
19
19
|
clippy::clone_on_copy
|
|
20
20
|
)]
|
|
21
|
+
#![allow(clippy::redundant_closure)]
|
|
21
22
|
#![allow(deprecated)]
|
|
22
23
|
|
|
23
24
|
use async_trait::async_trait;
|
|
@@ -1148,6 +1149,9 @@ pub struct BrowserConfig {
|
|
|
1148
1149
|
session_affinity: bool,
|
|
1149
1150
|
chrome_path: Option<String>,
|
|
1150
1151
|
chrome_args: Vec<String>,
|
|
1152
|
+
scroll_containers: bool,
|
|
1153
|
+
dom_quiet_window: u64,
|
|
1154
|
+
dom_quiet_cap: u64,
|
|
1151
1155
|
}
|
|
1152
1156
|
|
|
1153
1157
|
unsafe impl IntoValueFromNative for BrowserConfig {}
|
|
@@ -1197,6 +1201,9 @@ impl std::fmt::Debug for BrowserConfig {
|
|
|
1197
1201
|
debug.field("session_affinity", &self.session_affinity);
|
|
1198
1202
|
debug.field("chrome_path", &self.chrome_path);
|
|
1199
1203
|
debug.field("chrome_args", &"<redacted>");
|
|
1204
|
+
debug.field("scroll_containers", &self.scroll_containers);
|
|
1205
|
+
debug.field("dom_quiet_window", &self.dom_quiet_window);
|
|
1206
|
+
debug.field("dom_quiet_cap", &self.dom_quiet_cap);
|
|
1200
1207
|
debug.finish()
|
|
1201
1208
|
}
|
|
1202
1209
|
}
|
|
@@ -1375,6 +1382,33 @@ impl BrowserConfig {
|
|
|
1375
1382
|
})?,
|
|
1376
1383
|
None => Default::default(),
|
|
1377
1384
|
},
|
|
1385
|
+
scroll_containers: match kwargs.get(ruby.to_symbol("scroll_containers")) {
|
|
1386
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
1387
|
+
magnus::Error::new(
|
|
1388
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1389
|
+
format!("invalid value for `scroll_containers`: {}", e),
|
|
1390
|
+
)
|
|
1391
|
+
})?,
|
|
1392
|
+
None => false,
|
|
1393
|
+
},
|
|
1394
|
+
dom_quiet_window: match kwargs.get(ruby.to_symbol("dom_quiet_window")) {
|
|
1395
|
+
Some(v) => u64::try_convert(v).map_err(|e| {
|
|
1396
|
+
magnus::Error::new(
|
|
1397
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1398
|
+
format!("invalid value for `dom_quiet_window`: {}", e),
|
|
1399
|
+
)
|
|
1400
|
+
})?,
|
|
1401
|
+
None => 150,
|
|
1402
|
+
},
|
|
1403
|
+
dom_quiet_cap: match kwargs.get(ruby.to_symbol("dom_quiet_cap")) {
|
|
1404
|
+
Some(v) => u64::try_convert(v).map_err(|e| {
|
|
1405
|
+
magnus::Error::new(
|
|
1406
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1407
|
+
format!("invalid value for `dom_quiet_cap`: {}", e),
|
|
1408
|
+
)
|
|
1409
|
+
})?,
|
|
1410
|
+
None => 4000,
|
|
1411
|
+
},
|
|
1378
1412
|
})
|
|
1379
1413
|
}
|
|
1380
1414
|
|
|
@@ -1445,6 +1479,18 @@ impl BrowserConfig {
|
|
|
1445
1479
|
fn chrome_args(&self) -> Vec<String> {
|
|
1446
1480
|
self.chrome_args.clone()
|
|
1447
1481
|
}
|
|
1482
|
+
|
|
1483
|
+
fn scroll_containers(&self) -> bool {
|
|
1484
|
+
self.scroll_containers
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
fn dom_quiet_window(&self) -> u64 {
|
|
1488
|
+
self.dom_quiet_window.clone()
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
fn dom_quiet_cap(&self) -> u64 {
|
|
1492
|
+
self.dom_quiet_cap.clone()
|
|
1493
|
+
}
|
|
1448
1494
|
}
|
|
1449
1495
|
|
|
1450
1496
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
@@ -3673,6 +3719,17 @@ pub struct ContentConfig {
|
|
|
3673
3719
|
wrap_width: usize,
|
|
3674
3720
|
include_document_structure: bool,
|
|
3675
3721
|
extract_metadata: bool,
|
|
3722
|
+
strip_newlines: bool,
|
|
3723
|
+
bullets: String,
|
|
3724
|
+
list_indent_width: usize,
|
|
3725
|
+
strong_em_symbol: String,
|
|
3726
|
+
compact_tables: bool,
|
|
3727
|
+
keep_inline_images_in: Vec<String>,
|
|
3728
|
+
keep_hidden: bool,
|
|
3729
|
+
expand_abbreviations: bool,
|
|
3730
|
+
escape_misc: bool,
|
|
3731
|
+
escape_asterisks: bool,
|
|
3732
|
+
include_icon_labels: bool,
|
|
3676
3733
|
}
|
|
3677
3734
|
|
|
3678
3735
|
unsafe impl IntoValueFromNative for ContentConfig {}
|
|
@@ -3841,6 +3898,105 @@ impl ContentConfig {
|
|
|
3841
3898
|
})?,
|
|
3842
3899
|
None => true,
|
|
3843
3900
|
},
|
|
3901
|
+
strip_newlines: match kwargs.get(ruby.to_symbol("strip_newlines")) {
|
|
3902
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3903
|
+
magnus::Error::new(
|
|
3904
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3905
|
+
format!("invalid value for `strip_newlines`: {}", e),
|
|
3906
|
+
)
|
|
3907
|
+
})?,
|
|
3908
|
+
None => false,
|
|
3909
|
+
},
|
|
3910
|
+
bullets: match kwargs.get(ruby.to_symbol("bullets")) {
|
|
3911
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
3912
|
+
magnus::Error::new(
|
|
3913
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3914
|
+
format!("invalid value for `bullets`: {}", e),
|
|
3915
|
+
)
|
|
3916
|
+
})?,
|
|
3917
|
+
None => "-*+".to_string(),
|
|
3918
|
+
},
|
|
3919
|
+
list_indent_width: match kwargs.get(ruby.to_symbol("list_indent_width")) {
|
|
3920
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
3921
|
+
magnus::Error::new(
|
|
3922
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3923
|
+
format!("invalid value for `list_indent_width`: {}", e),
|
|
3924
|
+
)
|
|
3925
|
+
})?,
|
|
3926
|
+
None => 2,
|
|
3927
|
+
},
|
|
3928
|
+
strong_em_symbol: match kwargs.get(ruby.to_symbol("strong_em_symbol")) {
|
|
3929
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
3930
|
+
magnus::Error::new(
|
|
3931
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3932
|
+
format!("invalid value for `strong_em_symbol`: {}", e),
|
|
3933
|
+
)
|
|
3934
|
+
})?,
|
|
3935
|
+
None => "*".to_string(),
|
|
3936
|
+
},
|
|
3937
|
+
compact_tables: match kwargs.get(ruby.to_symbol("compact_tables")) {
|
|
3938
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3939
|
+
magnus::Error::new(
|
|
3940
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3941
|
+
format!("invalid value for `compact_tables`: {}", e),
|
|
3942
|
+
)
|
|
3943
|
+
})?,
|
|
3944
|
+
None => false,
|
|
3945
|
+
},
|
|
3946
|
+
keep_inline_images_in: match kwargs.get(ruby.to_symbol("keep_inline_images_in")) {
|
|
3947
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
3948
|
+
magnus::Error::new(
|
|
3949
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3950
|
+
format!("invalid value for `keep_inline_images_in`: {}", e),
|
|
3951
|
+
)
|
|
3952
|
+
})?,
|
|
3953
|
+
None => Default::default(),
|
|
3954
|
+
},
|
|
3955
|
+
keep_hidden: match kwargs.get(ruby.to_symbol("keep_hidden")) {
|
|
3956
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3957
|
+
magnus::Error::new(
|
|
3958
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3959
|
+
format!("invalid value for `keep_hidden`: {}", e),
|
|
3960
|
+
)
|
|
3961
|
+
})?,
|
|
3962
|
+
None => false,
|
|
3963
|
+
},
|
|
3964
|
+
expand_abbreviations: match kwargs.get(ruby.to_symbol("expand_abbreviations")) {
|
|
3965
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3966
|
+
magnus::Error::new(
|
|
3967
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3968
|
+
format!("invalid value for `expand_abbreviations`: {}", e),
|
|
3969
|
+
)
|
|
3970
|
+
})?,
|
|
3971
|
+
None => true,
|
|
3972
|
+
},
|
|
3973
|
+
escape_misc: match kwargs.get(ruby.to_symbol("escape_misc")) {
|
|
3974
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3975
|
+
magnus::Error::new(
|
|
3976
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3977
|
+
format!("invalid value for `escape_misc`: {}", e),
|
|
3978
|
+
)
|
|
3979
|
+
})?,
|
|
3980
|
+
None => false,
|
|
3981
|
+
},
|
|
3982
|
+
escape_asterisks: match kwargs.get(ruby.to_symbol("escape_asterisks")) {
|
|
3983
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3984
|
+
magnus::Error::new(
|
|
3985
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3986
|
+
format!("invalid value for `escape_asterisks`: {}", e),
|
|
3987
|
+
)
|
|
3988
|
+
})?,
|
|
3989
|
+
None => false,
|
|
3990
|
+
},
|
|
3991
|
+
include_icon_labels: match kwargs.get(ruby.to_symbol("include_icon_labels")) {
|
|
3992
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3993
|
+
magnus::Error::new(
|
|
3994
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3995
|
+
format!("invalid value for `include_icon_labels`: {}", e),
|
|
3996
|
+
)
|
|
3997
|
+
})?,
|
|
3998
|
+
None => true,
|
|
3999
|
+
},
|
|
3844
4000
|
})
|
|
3845
4001
|
}
|
|
3846
4002
|
|
|
@@ -3895,6 +4051,50 @@ impl ContentConfig {
|
|
|
3895
4051
|
fn extract_metadata(&self) -> bool {
|
|
3896
4052
|
self.extract_metadata
|
|
3897
4053
|
}
|
|
4054
|
+
|
|
4055
|
+
fn strip_newlines(&self) -> bool {
|
|
4056
|
+
self.strip_newlines
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
fn bullets(&self) -> String {
|
|
4060
|
+
self.bullets.clone()
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
fn list_indent_width(&self) -> usize {
|
|
4064
|
+
self.list_indent_width
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
fn strong_em_symbol(&self) -> String {
|
|
4068
|
+
self.strong_em_symbol.clone()
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
fn compact_tables(&self) -> bool {
|
|
4072
|
+
self.compact_tables
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
fn keep_inline_images_in(&self) -> Vec<String> {
|
|
4076
|
+
self.keep_inline_images_in.clone()
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
fn keep_hidden(&self) -> bool {
|
|
4080
|
+
self.keep_hidden
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
fn expand_abbreviations(&self) -> bool {
|
|
4084
|
+
self.expand_abbreviations
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
fn escape_misc(&self) -> bool {
|
|
4088
|
+
self.escape_misc
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
fn escape_asterisks(&self) -> bool {
|
|
4092
|
+
self.escape_asterisks
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4095
|
+
fn include_icon_labels(&self) -> bool {
|
|
4096
|
+
self.include_icon_labels
|
|
4097
|
+
}
|
|
3898
4098
|
}
|
|
3899
4099
|
|
|
3900
4100
|
#[derive(Clone, Debug, serde::Serialize)]
|
|
@@ -4113,6 +4313,8 @@ pub struct ConversionOptions {
|
|
|
4113
4313
|
escape_ascii: bool,
|
|
4114
4314
|
code_language: String,
|
|
4115
4315
|
autolinks: bool,
|
|
4316
|
+
expand_abbreviations: bool,
|
|
4317
|
+
include_blockquote_citations: bool,
|
|
4116
4318
|
default_title: bool,
|
|
4117
4319
|
br_in_tables: bool,
|
|
4118
4320
|
compact_tables: bool,
|
|
@@ -4135,6 +4337,7 @@ pub struct ConversionOptions {
|
|
|
4135
4337
|
preserve_tags: Vec<String>,
|
|
4136
4338
|
skip_images: bool,
|
|
4137
4339
|
inline_data_media: InlineDataMedia,
|
|
4340
|
+
hidden_content: HiddenContent,
|
|
4138
4341
|
url_escape_style: UrlEscapeStyle,
|
|
4139
4342
|
link_style: LinkStyle,
|
|
4140
4343
|
output_format: HtmlToMarkdownRsOutputFormat,
|
|
@@ -4290,6 +4493,24 @@ impl ConversionOptions {
|
|
|
4290
4493
|
})?,
|
|
4291
4494
|
None => true,
|
|
4292
4495
|
},
|
|
4496
|
+
expand_abbreviations: match kwargs.get(ruby.to_symbol("expand_abbreviations")) {
|
|
4497
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
4498
|
+
magnus::Error::new(
|
|
4499
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
4500
|
+
format!("invalid value for `expand_abbreviations`: {}", e),
|
|
4501
|
+
)
|
|
4502
|
+
})?,
|
|
4503
|
+
None => true,
|
|
4504
|
+
},
|
|
4505
|
+
include_blockquote_citations: match kwargs.get(ruby.to_symbol("include_blockquote_citations")) {
|
|
4506
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
4507
|
+
magnus::Error::new(
|
|
4508
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
4509
|
+
format!("invalid value for `include_blockquote_citations`: {}", e),
|
|
4510
|
+
)
|
|
4511
|
+
})?,
|
|
4512
|
+
None => true,
|
|
4513
|
+
},
|
|
4293
4514
|
default_title: match kwargs.get(ruby.to_symbol("default_title")) {
|
|
4294
4515
|
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
4295
4516
|
magnus::Error::new(
|
|
@@ -4488,6 +4709,15 @@ impl ConversionOptions {
|
|
|
4488
4709
|
})?,
|
|
4489
4710
|
None => InlineDataMedia::Keep,
|
|
4490
4711
|
},
|
|
4712
|
+
hidden_content: match kwargs.get(ruby.to_symbol("hidden_content")) {
|
|
4713
|
+
Some(v) => HiddenContent::try_convert(v).map_err(|e| {
|
|
4714
|
+
magnus::Error::new(
|
|
4715
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
4716
|
+
format!("invalid value for `hidden_content`: {}", e),
|
|
4717
|
+
)
|
|
4718
|
+
})?,
|
|
4719
|
+
None => HiddenContent::Drop,
|
|
4720
|
+
},
|
|
4491
4721
|
url_escape_style: match kwargs.get(ruby.to_symbol("url_escape_style")) {
|
|
4492
4722
|
Some(v) => UrlEscapeStyle::try_convert(v).map_err(|e| {
|
|
4493
4723
|
magnus::Error::new(
|
|
@@ -4652,6 +4882,14 @@ impl ConversionOptions {
|
|
|
4652
4882
|
self.autolinks
|
|
4653
4883
|
}
|
|
4654
4884
|
|
|
4885
|
+
fn expand_abbreviations(&self) -> bool {
|
|
4886
|
+
self.expand_abbreviations
|
|
4887
|
+
}
|
|
4888
|
+
|
|
4889
|
+
fn include_blockquote_citations(&self) -> bool {
|
|
4890
|
+
self.include_blockquote_citations
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4655
4893
|
fn default_title(&self) -> bool {
|
|
4656
4894
|
self.default_title
|
|
4657
4895
|
}
|
|
@@ -4740,6 +4978,10 @@ impl ConversionOptions {
|
|
|
4740
4978
|
self.inline_data_media.clone()
|
|
4741
4979
|
}
|
|
4742
4980
|
|
|
4981
|
+
fn hidden_content(&self) -> HiddenContent {
|
|
4982
|
+
self.hidden_content.clone()
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4743
4985
|
fn url_escape_style(&self) -> UrlEscapeStyle {
|
|
4744
4986
|
self.url_escape_style.clone()
|
|
4745
4987
|
}
|
|
@@ -5120,6 +5362,8 @@ pub struct CrawlConfig {
|
|
|
5120
5362
|
save_browser_profile: bool,
|
|
5121
5363
|
ssrf: SsrfPolicy,
|
|
5122
5364
|
ssrf_deny_private_explicit: Option<bool>,
|
|
5365
|
+
danger_accept_invalid_certs: bool,
|
|
5366
|
+
subdomain_header_allowlist: Vec<String>,
|
|
5123
5367
|
}
|
|
5124
5368
|
|
|
5125
5369
|
unsafe impl IntoValueFromNative for CrawlConfig {}
|
|
@@ -5207,6 +5451,8 @@ impl std::fmt::Debug for CrawlConfig {
|
|
|
5207
5451
|
debug.field("save_browser_profile", &self.save_browser_profile);
|
|
5208
5452
|
debug.field("ssrf", &self.ssrf);
|
|
5209
5453
|
debug.field("ssrf_deny_private_explicit", &self.ssrf_deny_private_explicit);
|
|
5454
|
+
debug.field("danger_accept_invalid_certs", &self.danger_accept_invalid_certs);
|
|
5455
|
+
debug.field("subdomain_header_allowlist", &self.subdomain_header_allowlist);
|
|
5210
5456
|
debug.finish()
|
|
5211
5457
|
}
|
|
5212
5458
|
}
|
|
@@ -5384,7 +5630,7 @@ impl CrawlConfig {
|
|
|
5384
5630
|
format!("invalid value for `dedup_include_query`: {}", e),
|
|
5385
5631
|
)
|
|
5386
5632
|
})?,
|
|
5387
|
-
None =>
|
|
5633
|
+
None => true,
|
|
5388
5634
|
},
|
|
5389
5635
|
strip_tracking_params: match kwargs.get(ruby.to_symbol("strip_tracking_params")) {
|
|
5390
5636
|
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
@@ -5733,6 +5979,24 @@ impl CrawlConfig {
|
|
|
5733
5979
|
})?),
|
|
5734
5980
|
None => None,
|
|
5735
5981
|
},
|
|
5982
|
+
danger_accept_invalid_certs: match kwargs.get(ruby.to_symbol("danger_accept_invalid_certs")) {
|
|
5983
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
5984
|
+
magnus::Error::new(
|
|
5985
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
5986
|
+
format!("invalid value for `danger_accept_invalid_certs`: {}", e),
|
|
5987
|
+
)
|
|
5988
|
+
})?,
|
|
5989
|
+
None => false,
|
|
5990
|
+
},
|
|
5991
|
+
subdomain_header_allowlist: match kwargs.get(ruby.to_symbol("subdomain_header_allowlist")) {
|
|
5992
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
5993
|
+
magnus::Error::new(
|
|
5994
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
5995
|
+
format!("invalid value for `subdomain_header_allowlist`: {}", e),
|
|
5996
|
+
)
|
|
5997
|
+
})?,
|
|
5998
|
+
None => Default::default(),
|
|
5999
|
+
},
|
|
5736
6000
|
})
|
|
5737
6001
|
}
|
|
5738
6002
|
|
|
@@ -5955,6 +6219,14 @@ impl CrawlConfig {
|
|
|
5955
6219
|
fn ssrf_deny_private_explicit(&self) -> Option<bool> {
|
|
5956
6220
|
self.ssrf_deny_private_explicit
|
|
5957
6221
|
}
|
|
6222
|
+
|
|
6223
|
+
fn danger_accept_invalid_certs(&self) -> bool {
|
|
6224
|
+
self.danger_accept_invalid_certs
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
fn subdomain_header_allowlist(&self) -> Vec<String> {
|
|
6228
|
+
self.subdomain_header_allowlist.clone()
|
|
6229
|
+
}
|
|
5958
6230
|
}
|
|
5959
6231
|
|
|
5960
6232
|
#[derive(Clone, Debug, serde::Serialize)]
|
|
@@ -11114,6 +11386,96 @@ impl ExtractInput {
|
|
|
11114
11386
|
}
|
|
11115
11387
|
}
|
|
11116
11388
|
|
|
11389
|
+
#[derive(Clone, Debug, serde::Serialize)]
|
|
11390
|
+
#[serde(default)]
|
|
11391
|
+
#[magnus::wrap(class = "Xberg::ExtractInputWithOptions")]
|
|
11392
|
+
pub struct ExtractInputWithOptions {
|
|
11393
|
+
input: ExtractInput,
|
|
11394
|
+
use_layout_for_markdown: Option<bool>,
|
|
11395
|
+
}
|
|
11396
|
+
|
|
11397
|
+
unsafe impl IntoValueFromNative for ExtractInputWithOptions {}
|
|
11398
|
+
|
|
11399
|
+
impl magnus::TryConvert for ExtractInputWithOptions {
|
|
11400
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
11401
|
+
if let Ok(r) = <&ExtractInputWithOptions as magnus::TryConvert>::try_convert(val) {
|
|
11402
|
+
return Ok(r.clone());
|
|
11403
|
+
}
|
|
11404
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
11405
|
+
s
|
|
11406
|
+
} else {
|
|
11407
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
11408
|
+
magnus::Error::new(
|
|
11409
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
11410
|
+
format!("no implicit conversion into ExtractInputWithOptions: {}", e),
|
|
11411
|
+
)
|
|
11412
|
+
})?
|
|
11413
|
+
};
|
|
11414
|
+
serde_json::from_str::<ExtractInputWithOptions>(&json_str).map_err(|e| {
|
|
11415
|
+
magnus::Error::new(
|
|
11416
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
11417
|
+
format!("failed to deserialize ExtractInputWithOptions: {}", e),
|
|
11418
|
+
)
|
|
11419
|
+
})
|
|
11420
|
+
}
|
|
11421
|
+
}
|
|
11422
|
+
|
|
11423
|
+
unsafe impl TryConvertOwned for ExtractInputWithOptions {}
|
|
11424
|
+
impl<'de> serde::Deserialize<'de> for ExtractInputWithOptions {
|
|
11425
|
+
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
|
|
11426
|
+
where
|
|
11427
|
+
D: serde::Deserializer<'de>,
|
|
11428
|
+
{
|
|
11429
|
+
<xberg::ExtractInputWithOptions as serde::Deserialize>::deserialize(deserializer).map(Into::into)
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
|
|
11433
|
+
impl Default for ExtractInputWithOptions {
|
|
11434
|
+
fn default() -> Self {
|
|
11435
|
+
xberg::ExtractInputWithOptions::default().into()
|
|
11436
|
+
}
|
|
11437
|
+
}
|
|
11438
|
+
|
|
11439
|
+
impl ExtractInputWithOptions {
|
|
11440
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
11441
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
11442
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
11443
|
+
let (kwargs_opt,) = args.optional;
|
|
11444
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
11445
|
+
Ok(Self {
|
|
11446
|
+
input: match kwargs.get(ruby.to_symbol("input")) {
|
|
11447
|
+
Some(v) => ExtractInput::try_convert(v).map_err(|e| {
|
|
11448
|
+
magnus::Error::new(
|
|
11449
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
11450
|
+
format!("invalid value for `input`: {}", e),
|
|
11451
|
+
)
|
|
11452
|
+
})?,
|
|
11453
|
+
None => Default::default(),
|
|
11454
|
+
},
|
|
11455
|
+
use_layout_for_markdown: match kwargs
|
|
11456
|
+
.get(ruby.to_symbol("use_layout_for_markdown"))
|
|
11457
|
+
.filter(|v| !v.is_nil())
|
|
11458
|
+
{
|
|
11459
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
11460
|
+
magnus::Error::new(
|
|
11461
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
11462
|
+
format!("invalid value for `use_layout_for_markdown`: {}", e),
|
|
11463
|
+
)
|
|
11464
|
+
})?),
|
|
11465
|
+
None => None,
|
|
11466
|
+
},
|
|
11467
|
+
})
|
|
11468
|
+
}
|
|
11469
|
+
|
|
11470
|
+
fn input(&self) -> ExtractInput {
|
|
11471
|
+
self.input.clone()
|
|
11472
|
+
}
|
|
11473
|
+
|
|
11474
|
+
fn use_layout_for_markdown(&self) -> Option<bool> {
|
|
11475
|
+
self.use_layout_for_markdown
|
|
11476
|
+
}
|
|
11477
|
+
}
|
|
11478
|
+
|
|
11117
11479
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
11118
11480
|
#[serde(default)]
|
|
11119
11481
|
#[magnus::wrap(class = "Xberg::ExtractedDocument")]
|
|
@@ -13189,12 +13551,7 @@ impl ExtractionConfig {
|
|
|
13189
13551
|
|
|
13190
13552
|
..Default::default()
|
|
13191
13553
|
};
|
|
13192
|
-
let result = core_self.validate().map_err(
|
|
13193
|
-
magnus::Error::new(
|
|
13194
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
13195
|
-
e.to_string(),
|
|
13196
|
-
)
|
|
13197
|
-
})?;
|
|
13554
|
+
let result = core_self.validate().map_err(alef_magnus_err)?;
|
|
13198
13555
|
Ok(result)
|
|
13199
13556
|
}
|
|
13200
13557
|
|
|
@@ -16346,12 +16703,7 @@ impl HeuristicsConfig {
|
|
|
16346
16703
|
|
|
16347
16704
|
..Default::default()
|
|
16348
16705
|
};
|
|
16349
|
-
let result = core_self.validate().map_err(
|
|
16350
|
-
magnus::Error::new(
|
|
16351
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
16352
|
-
e.to_string(),
|
|
16353
|
-
)
|
|
16354
|
-
})?;
|
|
16706
|
+
let result = core_self.validate().map_err(alef_magnus_err)?;
|
|
16355
16707
|
Ok(result)
|
|
16356
16708
|
}
|
|
16357
16709
|
}
|
|
@@ -19470,6 +19822,7 @@ pub struct LayoutDetectionConfig {
|
|
|
19470
19822
|
table_overlap_preference: TableOverlapPreference,
|
|
19471
19823
|
acceleration: Option<AccelerationConfig>,
|
|
19472
19824
|
enable_chart_understanding: bool,
|
|
19825
|
+
model: LayoutDetectionModel,
|
|
19473
19826
|
}
|
|
19474
19827
|
|
|
19475
19828
|
#[cfg(feature = "layout-types")]
|
|
@@ -19602,6 +19955,15 @@ impl LayoutDetectionConfig {
|
|
|
19602
19955
|
})?,
|
|
19603
19956
|
None => false,
|
|
19604
19957
|
},
|
|
19958
|
+
model: match kwargs.get(ruby.to_symbol("model")) {
|
|
19959
|
+
Some(v) => LayoutDetectionModel::try_convert(v).map_err(|e| {
|
|
19960
|
+
magnus::Error::new(
|
|
19961
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
19962
|
+
format!("invalid value for `model`: {}", e),
|
|
19963
|
+
)
|
|
19964
|
+
})?,
|
|
19965
|
+
None => LayoutDetectionModel::RtDetr,
|
|
19966
|
+
},
|
|
19605
19967
|
})
|
|
19606
19968
|
}
|
|
19607
19969
|
|
|
@@ -19636,6 +19998,10 @@ impl LayoutDetectionConfig {
|
|
|
19636
19998
|
fn enable_chart_understanding(&self) -> bool {
|
|
19637
19999
|
self.enable_chart_understanding
|
|
19638
20000
|
}
|
|
20001
|
+
|
|
20002
|
+
fn model(&self) -> LayoutDetectionModel {
|
|
20003
|
+
self.model.clone()
|
|
20004
|
+
}
|
|
19639
20005
|
}
|
|
19640
20006
|
|
|
19641
20007
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
@@ -20611,12 +20977,7 @@ impl LlmConfig {
|
|
|
20611
20977
|
|
|
20612
20978
|
..Default::default()
|
|
20613
20979
|
};
|
|
20614
|
-
let result = core_self.validate().map_err(
|
|
20615
|
-
magnus::Error::new(
|
|
20616
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
20617
|
-
e.to_string(),
|
|
20618
|
-
)
|
|
20619
|
-
})?;
|
|
20980
|
+
let result = core_self.validate().map_err(alef_magnus_err)?;
|
|
20620
20981
|
Ok(result)
|
|
20621
20982
|
}
|
|
20622
20983
|
}
|
|
@@ -21234,12 +21595,7 @@ unsafe impl TryConvertOwned for MetaSchema {}
|
|
|
21234
21595
|
impl MetaSchema {
|
|
21235
21596
|
fn parse_preset(&self, path: String, raw: magnus::RString) -> Result<Preset, Error> {
|
|
21236
21597
|
let raw = unsafe { raw.as_slice().to_vec() };
|
|
21237
|
-
let result = self.inner.parse_preset(&path, &raw).map_err(
|
|
21238
|
-
magnus::Error::new(
|
|
21239
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
21240
|
-
e.to_string(),
|
|
21241
|
-
)
|
|
21242
|
-
})?;
|
|
21598
|
+
let result = self.inner.parse_preset(&path, &raw).map_err(alef_magnus_err)?;
|
|
21243
21599
|
Ok(result.into())
|
|
21244
21600
|
}
|
|
21245
21601
|
}
|
|
@@ -22434,7 +22790,7 @@ pub struct OcrConfig {
|
|
|
22434
22790
|
element_config: Option<OcrElementConfig>,
|
|
22435
22791
|
quality_thresholds: Option<OcrQualityThresholds>,
|
|
22436
22792
|
pipeline: Option<OcrPipelineConfig>,
|
|
22437
|
-
auto_rotate: bool
|
|
22793
|
+
auto_rotate: Option<bool>,
|
|
22438
22794
|
vlm_fallback: VlmFallbackPolicy,
|
|
22439
22795
|
vlm_config: Option<LlmConfig>,
|
|
22440
22796
|
vlm_prompt: Option<String>,
|
|
@@ -22596,14 +22952,14 @@ impl OcrConfig {
|
|
|
22596
22952
|
})?),
|
|
22597
22953
|
None => None,
|
|
22598
22954
|
},
|
|
22599
|
-
auto_rotate: match kwargs.get(ruby.to_symbol("auto_rotate")) {
|
|
22600
|
-
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
22955
|
+
auto_rotate: match kwargs.get(ruby.to_symbol("auto_rotate")).filter(|v| !v.is_nil()) {
|
|
22956
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
22601
22957
|
magnus::Error::new(
|
|
22602
22958
|
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
22603
22959
|
format!("invalid value for `auto_rotate`: {}", e),
|
|
22604
22960
|
)
|
|
22605
|
-
})
|
|
22606
|
-
None =>
|
|
22961
|
+
})?),
|
|
22962
|
+
None => None,
|
|
22607
22963
|
},
|
|
22608
22964
|
vlm_fallback: match kwargs.get(ruby.to_symbol("vlm_fallback")) {
|
|
22609
22965
|
Some(v) => VlmFallbackPolicy::try_convert(v).map_err(|e| {
|
|
@@ -22724,7 +23080,7 @@ impl OcrConfig {
|
|
|
22724
23080
|
self.pipeline.clone()
|
|
22725
23081
|
}
|
|
22726
23082
|
|
|
22727
|
-
fn auto_rotate(&self) -> bool {
|
|
23083
|
+
fn auto_rotate(&self) -> Option<bool> {
|
|
22728
23084
|
self.auto_rotate
|
|
22729
23085
|
}
|
|
22730
23086
|
|
|
@@ -23781,6 +24137,7 @@ pub struct OcrQualityThresholds {
|
|
|
23781
24137
|
min_words_for_ocr_output_check: usize,
|
|
23782
24138
|
max_ocr_output_dict_invalid_word_ratio: f64,
|
|
23783
24139
|
discard_suspected_ocr_noise: bool,
|
|
24140
|
+
prune_symbol_noise_lines: bool,
|
|
23784
24141
|
min_avg_word_length: f64,
|
|
23785
24142
|
min_words_for_avg_length_check: usize,
|
|
23786
24143
|
min_consecutive_repeat_ratio: f64,
|
|
@@ -23966,6 +24323,15 @@ impl OcrQualityThresholds {
|
|
|
23966
24323
|
})?,
|
|
23967
24324
|
None => false,
|
|
23968
24325
|
},
|
|
24326
|
+
prune_symbol_noise_lines: match kwargs.get(ruby.to_symbol("prune_symbol_noise_lines")) {
|
|
24327
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
24328
|
+
magnus::Error::new(
|
|
24329
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
24330
|
+
format!("invalid value for `prune_symbol_noise_lines`: {}", e),
|
|
24331
|
+
)
|
|
24332
|
+
})?,
|
|
24333
|
+
None => true,
|
|
24334
|
+
},
|
|
23969
24335
|
min_avg_word_length: match kwargs.get(ruby.to_symbol("min_avg_word_length")) {
|
|
23970
24336
|
Some(v) => f64::try_convert(v).map_err(|e| {
|
|
23971
24337
|
magnus::Error::new(
|
|
@@ -24138,6 +24504,10 @@ impl OcrQualityThresholds {
|
|
|
24138
24504
|
self.discard_suspected_ocr_noise
|
|
24139
24505
|
}
|
|
24140
24506
|
|
|
24507
|
+
fn prune_symbol_noise_lines(&self) -> bool {
|
|
24508
|
+
self.prune_symbol_noise_lines
|
|
24509
|
+
}
|
|
24510
|
+
|
|
24141
24511
|
fn min_avg_word_length(&self) -> f64 {
|
|
24142
24512
|
self.min_avg_word_length
|
|
24143
24513
|
}
|
|
@@ -27480,12 +27850,7 @@ impl PdfConfig {
|
|
|
27480
27850
|
|
|
27481
27851
|
..Default::default()
|
|
27482
27852
|
};
|
|
27483
|
-
let result = core_self.validate().map_err(
|
|
27484
|
-
magnus::Error::new(
|
|
27485
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
27486
|
-
e.to_string(),
|
|
27487
|
-
)
|
|
27488
|
-
})?;
|
|
27853
|
+
let result = core_self.validate().map_err(alef_magnus_err)?;
|
|
27489
27854
|
Ok(result)
|
|
27490
27855
|
}
|
|
27491
27856
|
}
|
|
@@ -30389,12 +30754,7 @@ impl RedactionConfig {
|
|
|
30389
30754
|
|
|
30390
30755
|
..Default::default()
|
|
30391
30756
|
};
|
|
30392
|
-
let result = core_self.validate().map_err(
|
|
30393
|
-
magnus::Error::new(
|
|
30394
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
30395
|
-
e.to_string(),
|
|
30396
|
-
)
|
|
30397
|
-
})?;
|
|
30757
|
+
let result = core_self.validate().map_err(alef_magnus_err)?;
|
|
30398
30758
|
Ok(result)
|
|
30399
30759
|
}
|
|
30400
30760
|
}
|
|
@@ -30862,12 +31222,7 @@ impl Registry {
|
|
|
30862
31222
|
.lock()
|
|
30863
31223
|
.unwrap()
|
|
30864
31224
|
.extend_from_dir(std::path::Path::new(&dir))
|
|
30865
|
-
.map_err(
|
|
30866
|
-
magnus::Error::new(
|
|
30867
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
30868
|
-
e.to_string(),
|
|
30869
|
-
)
|
|
30870
|
-
})?;
|
|
31225
|
+
.map_err(alef_magnus_err)?;
|
|
30871
31226
|
Ok(result)
|
|
30872
31227
|
}
|
|
30873
31228
|
}
|
|
@@ -38695,8 +39050,168 @@ impl Default for FormatMetadata {
|
|
|
38695
39050
|
}
|
|
38696
39051
|
}
|
|
38697
39052
|
|
|
39053
|
+
// Reconstruct the generated Data variant class instead of a plain Hash, keeping
|
|
39054
|
+
// IntoValue symmetric with TryConvert (which accepts those variant classes).
|
|
39055
|
+
// Falls back to the JSON shape when the Ruby classes are not loaded.
|
|
39056
|
+
impl FormatMetadata {
|
|
39057
|
+
fn tagged_ruby_variant(&self, handle: &Ruby) -> Option<magnus::Value> {
|
|
39058
|
+
match self {
|
|
39059
|
+
FormatMetadata::Pdf { _0: payload } => {
|
|
39060
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39061
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataPdf").ok()?;
|
|
39062
|
+
let payload = (*payload).clone();
|
|
39063
|
+
let value = <PdfMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39064
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39065
|
+
}
|
|
39066
|
+
FormatMetadata::Docx { _0: payload } => {
|
|
39067
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39068
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataDocx").ok()?;
|
|
39069
|
+
let payload = (**payload).clone();
|
|
39070
|
+
let value = <DocxMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39071
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39072
|
+
}
|
|
39073
|
+
FormatMetadata::Excel { _0: payload } => {
|
|
39074
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39075
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataExcel").ok()?;
|
|
39076
|
+
let payload = (*payload).clone();
|
|
39077
|
+
let value = <ExcelMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39078
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39079
|
+
}
|
|
39080
|
+
FormatMetadata::Email { _0: payload } => {
|
|
39081
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39082
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataEmail").ok()?;
|
|
39083
|
+
let payload = (*payload).clone();
|
|
39084
|
+
let value = <EmailMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39085
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39086
|
+
}
|
|
39087
|
+
FormatMetadata::Pptx { _0: payload } => {
|
|
39088
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39089
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataPptx").ok()?;
|
|
39090
|
+
let payload = (*payload).clone();
|
|
39091
|
+
let value = <PptxMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39092
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39093
|
+
}
|
|
39094
|
+
FormatMetadata::Archive { _0: payload } => {
|
|
39095
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39096
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataArchive").ok()?;
|
|
39097
|
+
let payload = (*payload).clone();
|
|
39098
|
+
let value = <ArchiveMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39099
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39100
|
+
}
|
|
39101
|
+
FormatMetadata::Image { _0: payload } => {
|
|
39102
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39103
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataImage").ok()?;
|
|
39104
|
+
let payload = (*payload).clone();
|
|
39105
|
+
let value = <ImageMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39106
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39107
|
+
}
|
|
39108
|
+
FormatMetadata::Xml { _0: payload } => {
|
|
39109
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39110
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataXml").ok()?;
|
|
39111
|
+
let payload = (*payload).clone();
|
|
39112
|
+
let value = <XmlMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39113
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39114
|
+
}
|
|
39115
|
+
FormatMetadata::Text { _0: payload } => {
|
|
39116
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39117
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataText").ok()?;
|
|
39118
|
+
let payload = (*payload).clone();
|
|
39119
|
+
let value = <TextMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39120
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39121
|
+
}
|
|
39122
|
+
FormatMetadata::Html { _0: payload } => {
|
|
39123
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39124
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataHtml").ok()?;
|
|
39125
|
+
let payload = (**payload).clone();
|
|
39126
|
+
let value = <HtmlMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39127
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39128
|
+
}
|
|
39129
|
+
FormatMetadata::Ocr { _0: payload } => {
|
|
39130
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39131
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataOcr").ok()?;
|
|
39132
|
+
let payload = (*payload).clone();
|
|
39133
|
+
let value = <OcrMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39134
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39135
|
+
}
|
|
39136
|
+
FormatMetadata::Csv { _0: payload } => {
|
|
39137
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39138
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataCsv").ok()?;
|
|
39139
|
+
let payload = (*payload).clone();
|
|
39140
|
+
let value = <CsvMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39141
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39142
|
+
}
|
|
39143
|
+
FormatMetadata::Bibtex { _0: payload } => {
|
|
39144
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39145
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataBibtex").ok()?;
|
|
39146
|
+
let payload = (*payload).clone();
|
|
39147
|
+
let value = <BibtexMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39148
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39149
|
+
}
|
|
39150
|
+
FormatMetadata::Citation { _0: payload } => {
|
|
39151
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39152
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataCitation").ok()?;
|
|
39153
|
+
let payload = (*payload).clone();
|
|
39154
|
+
let value = <CitationMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39155
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39156
|
+
}
|
|
39157
|
+
FormatMetadata::FictionBook { _0: payload } => {
|
|
39158
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39159
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataFictionBook").ok()?;
|
|
39160
|
+
let payload = (*payload).clone();
|
|
39161
|
+
let value = <FictionBookMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39162
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39163
|
+
}
|
|
39164
|
+
FormatMetadata::Dbf { _0: payload } => {
|
|
39165
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39166
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataDbf").ok()?;
|
|
39167
|
+
let payload = (*payload).clone();
|
|
39168
|
+
let value = <DbfMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39169
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39170
|
+
}
|
|
39171
|
+
FormatMetadata::Jats { _0: payload } => {
|
|
39172
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39173
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataJats").ok()?;
|
|
39174
|
+
let payload = (*payload).clone();
|
|
39175
|
+
let value = <JatsMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39176
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39177
|
+
}
|
|
39178
|
+
FormatMetadata::Epub { _0: payload } => {
|
|
39179
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39180
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataEpub").ok()?;
|
|
39181
|
+
let payload = (*payload).clone();
|
|
39182
|
+
let value = <EpubMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39183
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39184
|
+
}
|
|
39185
|
+
FormatMetadata::Pst { _0: payload } => {
|
|
39186
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39187
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataPst").ok()?;
|
|
39188
|
+
let payload = (*payload).clone();
|
|
39189
|
+
let value = <PstMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39190
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39191
|
+
}
|
|
39192
|
+
FormatMetadata::Audio { _0: payload } => {
|
|
39193
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39194
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataAudio").ok()?;
|
|
39195
|
+
let payload = (*payload).clone();
|
|
39196
|
+
let value = <AudioMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39197
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39198
|
+
}
|
|
39199
|
+
FormatMetadata::Code { _0: payload } => {
|
|
39200
|
+
// Resolve the variant before wrapping a payload whose Ruby class may also be absent.
|
|
39201
|
+
let class = handle.eval::<magnus::RClass>("Xberg::FormatMetadataCode").ok()?;
|
|
39202
|
+
let payload = (*payload).clone();
|
|
39203
|
+
let value = <CodeMetadata as magnus::IntoValue>::into_value_with(payload, handle);
|
|
39204
|
+
class.funcall::<_, _, magnus::Value>("new", (value,)).ok()
|
|
39205
|
+
}
|
|
39206
|
+
}
|
|
39207
|
+
}
|
|
39208
|
+
}
|
|
39209
|
+
|
|
38698
39210
|
impl magnus::IntoValue for FormatMetadata {
|
|
38699
39211
|
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
39212
|
+
if let Some(instance) = self.tagged_ruby_variant(handle) {
|
|
39213
|
+
return instance;
|
|
39214
|
+
}
|
|
38700
39215
|
match serde_json::to_value(&self) {
|
|
38701
39216
|
Ok(v) => json_to_ruby(handle, v),
|
|
38702
39217
|
Err(_) => handle.qnil().into_value_with(handle),
|
|
@@ -39161,6 +39676,58 @@ impl magnus::TryConvert for HeadingStyle {
|
|
|
39161
39676
|
unsafe impl IntoValueFromNative for HeadingStyle {}
|
|
39162
39677
|
unsafe impl TryConvertOwned for HeadingStyle {}
|
|
39163
39678
|
|
|
39679
|
+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
|
|
39680
|
+
pub enum HiddenContent {
|
|
39681
|
+
Drop,
|
|
39682
|
+
Reachable,
|
|
39683
|
+
All,
|
|
39684
|
+
}
|
|
39685
|
+
|
|
39686
|
+
impl Default for HiddenContent {
|
|
39687
|
+
fn default() -> Self {
|
|
39688
|
+
Self::Drop
|
|
39689
|
+
}
|
|
39690
|
+
}
|
|
39691
|
+
|
|
39692
|
+
impl magnus::IntoValue for HiddenContent {
|
|
39693
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
39694
|
+
let sym = match self {
|
|
39695
|
+
HiddenContent::Drop => "Drop",
|
|
39696
|
+
HiddenContent::Reachable => "Reachable",
|
|
39697
|
+
HiddenContent::All => "All",
|
|
39698
|
+
};
|
|
39699
|
+
handle.to_symbol(sym).into_value_with(handle)
|
|
39700
|
+
}
|
|
39701
|
+
}
|
|
39702
|
+
|
|
39703
|
+
impl magnus::TryConvert for HiddenContent {
|
|
39704
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
39705
|
+
// IntoValue emits Symbols, including when this enum is a Hash key.
|
|
39706
|
+
// Accept that exact representation as well as String inputs; do not
|
|
39707
|
+
// coerce arbitrary objects through to_s.
|
|
39708
|
+
let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
|
|
39709
|
+
symbol.name()?.into_owned()
|
|
39710
|
+
} else {
|
|
39711
|
+
magnus::TryConvert::try_convert(val)?
|
|
39712
|
+
};
|
|
39713
|
+
// Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
|
|
39714
|
+
// emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
|
|
39715
|
+
// existing consumer code written in any of those styles keep working.
|
|
39716
|
+
match s.as_str() {
|
|
39717
|
+
"Drop" | "drop" => Ok(HiddenContent::Drop),
|
|
39718
|
+
"Reachable" | "reachable" => Ok(HiddenContent::Reachable),
|
|
39719
|
+
"All" | "all" => Ok(HiddenContent::All),
|
|
39720
|
+
other => Err(magnus::Error::new(
|
|
39721
|
+
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
39722
|
+
format!("invalid HiddenContent value: {other}"),
|
|
39723
|
+
)),
|
|
39724
|
+
}
|
|
39725
|
+
}
|
|
39726
|
+
}
|
|
39727
|
+
|
|
39728
|
+
unsafe impl IntoValueFromNative for HiddenContent {}
|
|
39729
|
+
unsafe impl TryConvertOwned for HiddenContent {}
|
|
39730
|
+
|
|
39164
39731
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
|
|
39165
39732
|
pub enum HighlightStyle {
|
|
39166
39733
|
DoubleEqual,
|
|
@@ -40004,6 +40571,56 @@ impl magnus::TryConvert for LayoutClass {
|
|
|
40004
40571
|
unsafe impl IntoValueFromNative for LayoutClass {}
|
|
40005
40572
|
unsafe impl TryConvertOwned for LayoutClass {}
|
|
40006
40573
|
|
|
40574
|
+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
|
|
40575
|
+
#[serde(rename_all = "snake_case")]
|
|
40576
|
+
pub enum LayoutDetectionModel {
|
|
40577
|
+
RtDetr,
|
|
40578
|
+
PpDocLayoutV3,
|
|
40579
|
+
}
|
|
40580
|
+
|
|
40581
|
+
impl Default for LayoutDetectionModel {
|
|
40582
|
+
fn default() -> Self {
|
|
40583
|
+
Self::RtDetr
|
|
40584
|
+
}
|
|
40585
|
+
}
|
|
40586
|
+
|
|
40587
|
+
impl magnus::IntoValue for LayoutDetectionModel {
|
|
40588
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
40589
|
+
let sym = match self {
|
|
40590
|
+
LayoutDetectionModel::RtDetr => "rt_detr",
|
|
40591
|
+
LayoutDetectionModel::PpDocLayoutV3 => "pp_doc_layout_v3",
|
|
40592
|
+
};
|
|
40593
|
+
handle.to_symbol(sym).into_value_with(handle)
|
|
40594
|
+
}
|
|
40595
|
+
}
|
|
40596
|
+
|
|
40597
|
+
impl magnus::TryConvert for LayoutDetectionModel {
|
|
40598
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
40599
|
+
// IntoValue emits Symbols, including when this enum is a Hash key.
|
|
40600
|
+
// Accept that exact representation as well as String inputs; do not
|
|
40601
|
+
// coerce arbitrary objects through to_s.
|
|
40602
|
+
let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
|
|
40603
|
+
symbol.name()?.into_owned()
|
|
40604
|
+
} else {
|
|
40605
|
+
magnus::TryConvert::try_convert(val)?
|
|
40606
|
+
};
|
|
40607
|
+
// Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
|
|
40608
|
+
// emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
|
|
40609
|
+
// existing consumer code written in any of those styles keep working.
|
|
40610
|
+
match s.as_str() {
|
|
40611
|
+
"rt_detr" | "RtDetr" => Ok(LayoutDetectionModel::RtDetr),
|
|
40612
|
+
"pp_doc_layout_v3" | "PpDocLayoutV3" => Ok(LayoutDetectionModel::PpDocLayoutV3),
|
|
40613
|
+
other => Err(magnus::Error::new(
|
|
40614
|
+
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
40615
|
+
format!("invalid LayoutDetectionModel value: {other}"),
|
|
40616
|
+
)),
|
|
40617
|
+
}
|
|
40618
|
+
}
|
|
40619
|
+
}
|
|
40620
|
+
|
|
40621
|
+
unsafe impl IntoValueFromNative for LayoutDetectionModel {}
|
|
40622
|
+
unsafe impl TryConvertOwned for LayoutDetectionModel {}
|
|
40623
|
+
|
|
40007
40624
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
|
|
40008
40625
|
#[serde(rename_all = "snake_case")]
|
|
40009
40626
|
pub enum LayoutStrategy {
|
|
@@ -43248,11 +43865,11 @@ fn classify_chunks_owned(result: magnus::Value, config: magnus::Value) -> Result
|
|
|
43248
43865
|
.enable_all()
|
|
43249
43866
|
.build()
|
|
43250
43867
|
.map_err(|e| e.to_string())?;
|
|
43251
|
-
rt.block_on(async { xberg::text::classification::classify_chunks_owned(result_core, &config_core).await })
|
|
43252
|
-
.map_err(|e| e.to_string())
|
|
43868
|
+
Ok(rt.block_on(async { xberg::text::classification::classify_chunks_owned(result_core, &config_core).await }))
|
|
43253
43869
|
});
|
|
43254
43870
|
let result = async_result
|
|
43255
43871
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
43872
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43256
43873
|
Ok(result.into())
|
|
43257
43874
|
}
|
|
43258
43875
|
|
|
@@ -43280,11 +43897,11 @@ fn classify_chunks_owned_async(result: magnus::Value, config: magnus::Value) ->
|
|
|
43280
43897
|
.enable_all()
|
|
43281
43898
|
.build()
|
|
43282
43899
|
.map_err(|e| e.to_string())?;
|
|
43283
|
-
rt.block_on(async { xberg::text::classification::classify_chunks_owned(result_core, &config_core).await })
|
|
43284
|
-
.map_err(|e| e.to_string())
|
|
43900
|
+
Ok(rt.block_on(async { xberg::text::classification::classify_chunks_owned(result_core, &config_core).await }))
|
|
43285
43901
|
});
|
|
43286
43902
|
let result = async_result
|
|
43287
43903
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
43904
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43288
43905
|
Ok(result.into())
|
|
43289
43906
|
}
|
|
43290
43907
|
|
|
@@ -43340,11 +43957,11 @@ fn extract(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
|
43340
43957
|
.enable_all()
|
|
43341
43958
|
.build()
|
|
43342
43959
|
.map_err(|e| e.to_string())?;
|
|
43343
|
-
rt.block_on(async { xberg::extract(input_core, &config_core).await })
|
|
43344
|
-
.map_err(|e| e.to_string())
|
|
43960
|
+
Ok(rt.block_on(async { xberg::extract(input_core, &config_core).await }))
|
|
43345
43961
|
});
|
|
43346
43962
|
let result = async_result
|
|
43347
43963
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
43964
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43348
43965
|
Ok(result.into())
|
|
43349
43966
|
}
|
|
43350
43967
|
|
|
@@ -43380,11 +43997,11 @@ fn extract_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
|
43380
43997
|
.enable_all()
|
|
43381
43998
|
.build()
|
|
43382
43999
|
.map_err(|e| e.to_string())?;
|
|
43383
|
-
rt.block_on(async { xberg::extract(input_core, &config_core).await })
|
|
43384
|
-
.map_err(|e| e.to_string())
|
|
44000
|
+
Ok(rt.block_on(async { xberg::extract(input_core, &config_core).await }))
|
|
43385
44001
|
});
|
|
43386
44002
|
let result = async_result
|
|
43387
44003
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44004
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43388
44005
|
Ok(result.into())
|
|
43389
44006
|
}
|
|
43390
44007
|
|
|
@@ -43412,11 +44029,11 @@ fn extract_batch(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
|
43412
44029
|
.enable_all()
|
|
43413
44030
|
.build()
|
|
43414
44031
|
.map_err(|e| e.to_string())?;
|
|
43415
|
-
rt.block_on(async { xberg::extract_batch(inputs_core, &config_core).await })
|
|
43416
|
-
.map_err(|e| e.to_string())
|
|
44032
|
+
Ok(rt.block_on(async { xberg::extract_batch(inputs_core, &config_core).await }))
|
|
43417
44033
|
});
|
|
43418
44034
|
let result = async_result
|
|
43419
44035
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44036
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43420
44037
|
Ok(result.into())
|
|
43421
44038
|
}
|
|
43422
44039
|
|
|
@@ -43444,11 +44061,141 @@ fn extract_batch_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error
|
|
|
43444
44061
|
.enable_all()
|
|
43445
44062
|
.build()
|
|
43446
44063
|
.map_err(|e| e.to_string())?;
|
|
43447
|
-
rt.block_on(async { xberg::extract_batch(inputs_core, &config_core).await })
|
|
43448
|
-
.map_err(|e| e.to_string())
|
|
44064
|
+
Ok(rt.block_on(async { xberg::extract_batch(inputs_core, &config_core).await }))
|
|
43449
44065
|
});
|
|
43450
44066
|
let result = async_result
|
|
43451
44067
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44068
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44069
|
+
Ok(result.into())
|
|
44070
|
+
}
|
|
44071
|
+
|
|
44072
|
+
fn extract_batch_with_input_options(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
44073
|
+
let args = magnus::scan_args::scan_args::<(Vec<ExtractInputWithOptions>,), (Option<magnus::Value>,), (), (), (), ()>(
|
|
44074
|
+
args,
|
|
44075
|
+
)?;
|
|
44076
|
+
let (inputs,) = args.required;
|
|
44077
|
+
|
|
44078
|
+
let (config,) = args.optional;
|
|
44079
|
+
|
|
44080
|
+
let inputs_core: Vec<xberg::ExtractInputWithOptions> = inputs.into_iter().map(Into::into).collect();
|
|
44081
|
+
let config_core: xberg::ExtractionConfig = match config {
|
|
44082
|
+
Some(_v) if !_v.is_nil() => {
|
|
44083
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(_v).map_err(|e| {
|
|
44084
|
+
magnus::Error::new(
|
|
44085
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44086
|
+
e.to_string(),
|
|
44087
|
+
)
|
|
44088
|
+
})?;
|
|
44089
|
+
binding_val.into()
|
|
44090
|
+
}
|
|
44091
|
+
_ => Default::default(),
|
|
44092
|
+
};
|
|
44093
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44094
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44095
|
+
.enable_all()
|
|
44096
|
+
.build()
|
|
44097
|
+
.map_err(|e| e.to_string())?;
|
|
44098
|
+
Ok(rt.block_on(async { xberg::extract_batch_with_input_options(inputs_core, &config_core).await }))
|
|
44099
|
+
});
|
|
44100
|
+
let result = async_result
|
|
44101
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44102
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44103
|
+
Ok(result.into())
|
|
44104
|
+
}
|
|
44105
|
+
|
|
44106
|
+
fn extract_batch_with_input_options_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
44107
|
+
let args = magnus::scan_args::scan_args::<(Vec<ExtractInputWithOptions>,), (Option<magnus::Value>,), (), (), (), ()>(
|
|
44108
|
+
args,
|
|
44109
|
+
)?;
|
|
44110
|
+
let (inputs,) = args.required;
|
|
44111
|
+
|
|
44112
|
+
let (config,) = args.optional;
|
|
44113
|
+
|
|
44114
|
+
let inputs_core: Vec<xberg::ExtractInputWithOptions> = inputs.into_iter().map(Into::into).collect();
|
|
44115
|
+
let config_core: xberg::ExtractionConfig = match config {
|
|
44116
|
+
Some(_v) if !_v.is_nil() => {
|
|
44117
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(_v).map_err(|e| {
|
|
44118
|
+
magnus::Error::new(
|
|
44119
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44120
|
+
e.to_string(),
|
|
44121
|
+
)
|
|
44122
|
+
})?;
|
|
44123
|
+
binding_val.into()
|
|
44124
|
+
}
|
|
44125
|
+
_ => Default::default(),
|
|
44126
|
+
};
|
|
44127
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44128
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44129
|
+
.enable_all()
|
|
44130
|
+
.build()
|
|
44131
|
+
.map_err(|e| e.to_string())?;
|
|
44132
|
+
Ok(rt.block_on(async { xberg::extract_batch_with_input_options(inputs_core, &config_core).await }))
|
|
44133
|
+
});
|
|
44134
|
+
let result = async_result
|
|
44135
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44136
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44137
|
+
Ok(result.into())
|
|
44138
|
+
}
|
|
44139
|
+
|
|
44140
|
+
fn extract_batch_with_input_options_json(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
44141
|
+
let args = magnus::scan_args::scan_args::<(String,), (Option<magnus::Value>,), (), (), (), ()>(args)?;
|
|
44142
|
+
let (inputs_json,) = args.required;
|
|
44143
|
+
|
|
44144
|
+
let (config,) = args.optional;
|
|
44145
|
+
|
|
44146
|
+
let config_core: xberg::ExtractionConfig = match config {
|
|
44147
|
+
Some(_v) if !_v.is_nil() => {
|
|
44148
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(_v).map_err(|e| {
|
|
44149
|
+
magnus::Error::new(
|
|
44150
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44151
|
+
e.to_string(),
|
|
44152
|
+
)
|
|
44153
|
+
})?;
|
|
44154
|
+
binding_val.into()
|
|
44155
|
+
}
|
|
44156
|
+
_ => Default::default(),
|
|
44157
|
+
};
|
|
44158
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44159
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44160
|
+
.enable_all()
|
|
44161
|
+
.build()
|
|
44162
|
+
.map_err(|e| e.to_string())?;
|
|
44163
|
+
Ok(rt.block_on(async { xberg::extract_batch_with_input_options_json(&inputs_json, &config_core).await }))
|
|
44164
|
+
});
|
|
44165
|
+
let result = async_result
|
|
44166
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44167
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44168
|
+
Ok(result.into())
|
|
44169
|
+
}
|
|
44170
|
+
|
|
44171
|
+
fn extract_batch_with_input_options_json_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
44172
|
+
let args = magnus::scan_args::scan_args::<(String,), (Option<magnus::Value>,), (), (), (), ()>(args)?;
|
|
44173
|
+
let (inputs_json,) = args.required;
|
|
44174
|
+
|
|
44175
|
+
let (config,) = args.optional;
|
|
44176
|
+
|
|
44177
|
+
let config_core: xberg::ExtractionConfig = match config {
|
|
44178
|
+
Some(_v) if !_v.is_nil() => {
|
|
44179
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(_v).map_err(|e| {
|
|
44180
|
+
magnus::Error::new(
|
|
44181
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44182
|
+
e.to_string(),
|
|
44183
|
+
)
|
|
44184
|
+
})?;
|
|
44185
|
+
binding_val.into()
|
|
44186
|
+
}
|
|
44187
|
+
_ => Default::default(),
|
|
44188
|
+
};
|
|
44189
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44190
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44191
|
+
.enable_all()
|
|
44192
|
+
.build()
|
|
44193
|
+
.map_err(|e| e.to_string())?;
|
|
44194
|
+
Ok(rt.block_on(async { xberg::extract_batch_with_input_options_json(&inputs_json, &config_core).await }))
|
|
44195
|
+
});
|
|
44196
|
+
let result = async_result
|
|
44197
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44198
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43452
44199
|
Ok(result.into())
|
|
43453
44200
|
}
|
|
43454
44201
|
|
|
@@ -43456,7 +44203,7 @@ fn extract_batch_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error
|
|
|
43456
44203
|
fn extract_with_external_redaction(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
43457
44204
|
let args = magnus::scan_args::scan_args::<
|
|
43458
44205
|
(magnus::Value, magnus::Value, String),
|
|
43459
|
-
(Option<magnus::Value>, Option<
|
|
44206
|
+
(Option<magnus::Value>, Option<magnus::Value>),
|
|
43460
44207
|
(),
|
|
43461
44208
|
(),
|
|
43462
44209
|
(),
|
|
@@ -43466,13 +44213,15 @@ fn extract_with_external_redaction(args: &[magnus::Value]) -> Result<ExtractionR
|
|
|
43466
44213
|
|
|
43467
44214
|
let (offset_encoding, max_findings) = args.optional;
|
|
43468
44215
|
|
|
43469
|
-
let offset_encoding: Option<String> = offset_encoding
|
|
43470
|
-
if v.is_nil()
|
|
43471
|
-
|
|
43472
|
-
|
|
43473
|
-
|
|
43474
|
-
|
|
43475
|
-
|
|
44216
|
+
let offset_encoding: Option<String> = match offset_encoding {
|
|
44217
|
+
Some(v) if !v.is_nil() => Some(String::try_convert(v)?),
|
|
44218
|
+
_ => None,
|
|
44219
|
+
};
|
|
44220
|
+
|
|
44221
|
+
let max_findings: Option<u32> = match max_findings {
|
|
44222
|
+
Some(v) if !v.is_nil() => Some(u32::try_convert(v)?),
|
|
44223
|
+
_ => None,
|
|
44224
|
+
};
|
|
43476
44225
|
|
|
43477
44226
|
let input_core: xberg::ExtractInput = {
|
|
43478
44227
|
let binding_val: ExtractInput = ExtractInput::try_convert(input).map_err(|e| {
|
|
@@ -43497,7 +44246,7 @@ fn extract_with_external_redaction(args: &[magnus::Value]) -> Result<ExtractionR
|
|
|
43497
44246
|
.enable_all()
|
|
43498
44247
|
.build()
|
|
43499
44248
|
.map_err(|e| e.to_string())?;
|
|
43500
|
-
rt.block_on(async {
|
|
44249
|
+
Ok(rt.block_on(async {
|
|
43501
44250
|
xberg::extract_with_external_redaction(
|
|
43502
44251
|
input_core,
|
|
43503
44252
|
&config_core,
|
|
@@ -43506,11 +44255,11 @@ fn extract_with_external_redaction(args: &[magnus::Value]) -> Result<ExtractionR
|
|
|
43506
44255
|
max_findings,
|
|
43507
44256
|
)
|
|
43508
44257
|
.await
|
|
43509
|
-
})
|
|
43510
|
-
.map_err(|e| e.to_string())
|
|
44258
|
+
}))
|
|
43511
44259
|
});
|
|
43512
44260
|
let result = async_result
|
|
43513
44261
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44262
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43514
44263
|
Ok(result.into())
|
|
43515
44264
|
}
|
|
43516
44265
|
|
|
@@ -43518,7 +44267,7 @@ fn extract_with_external_redaction(args: &[magnus::Value]) -> Result<ExtractionR
|
|
|
43518
44267
|
fn extract_with_external_redaction_async(args: &[magnus::Value]) -> Result<ExtractionResult, Error> {
|
|
43519
44268
|
let args = magnus::scan_args::scan_args::<
|
|
43520
44269
|
(magnus::Value, magnus::Value, String),
|
|
43521
|
-
(Option<magnus::Value>, Option<
|
|
44270
|
+
(Option<magnus::Value>, Option<magnus::Value>),
|
|
43522
44271
|
(),
|
|
43523
44272
|
(),
|
|
43524
44273
|
(),
|
|
@@ -43528,13 +44277,15 @@ fn extract_with_external_redaction_async(args: &[magnus::Value]) -> Result<Extra
|
|
|
43528
44277
|
|
|
43529
44278
|
let (offset_encoding, max_findings) = args.optional;
|
|
43530
44279
|
|
|
43531
|
-
let offset_encoding: Option<String> = offset_encoding
|
|
43532
|
-
if v.is_nil()
|
|
43533
|
-
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
44280
|
+
let offset_encoding: Option<String> = match offset_encoding {
|
|
44281
|
+
Some(v) if !v.is_nil() => Some(String::try_convert(v)?),
|
|
44282
|
+
_ => None,
|
|
44283
|
+
};
|
|
44284
|
+
|
|
44285
|
+
let max_findings: Option<u32> = match max_findings {
|
|
44286
|
+
Some(v) if !v.is_nil() => Some(u32::try_convert(v)?),
|
|
44287
|
+
_ => None,
|
|
44288
|
+
};
|
|
43538
44289
|
|
|
43539
44290
|
let input_core: xberg::ExtractInput = {
|
|
43540
44291
|
let binding_val: ExtractInput = ExtractInput::try_convert(input).map_err(|e| {
|
|
@@ -43559,7 +44310,7 @@ fn extract_with_external_redaction_async(args: &[magnus::Value]) -> Result<Extra
|
|
|
43559
44310
|
.enable_all()
|
|
43560
44311
|
.build()
|
|
43561
44312
|
.map_err(|e| e.to_string())?;
|
|
43562
|
-
rt.block_on(async {
|
|
44313
|
+
Ok(rt.block_on(async {
|
|
43563
44314
|
xberg::extract_with_external_redaction(
|
|
43564
44315
|
input_core,
|
|
43565
44316
|
&config_core,
|
|
@@ -43568,11 +44319,85 @@ fn extract_with_external_redaction_async(args: &[magnus::Value]) -> Result<Extra
|
|
|
43568
44319
|
max_findings,
|
|
43569
44320
|
)
|
|
43570
44321
|
.await
|
|
43571
|
-
})
|
|
43572
|
-
|
|
44322
|
+
}))
|
|
44323
|
+
});
|
|
44324
|
+
let result = async_result
|
|
44325
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44326
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44327
|
+
Ok(result.into())
|
|
44328
|
+
}
|
|
44329
|
+
|
|
44330
|
+
#[cfg(all(feature = "pdf", feature = "layout-detection"))]
|
|
44331
|
+
fn extract_with_layout_pages(
|
|
44332
|
+
input: magnus::Value,
|
|
44333
|
+
config: magnus::Value,
|
|
44334
|
+
pages: Vec<u32>,
|
|
44335
|
+
) -> Result<ExtractionResult, Error> {
|
|
44336
|
+
let input_core: xberg::ExtractInput = {
|
|
44337
|
+
let binding_val: ExtractInput = ExtractInput::try_convert(input).map_err(|e| {
|
|
44338
|
+
magnus::Error::new(
|
|
44339
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44340
|
+
e.to_string(),
|
|
44341
|
+
)
|
|
44342
|
+
})?;
|
|
44343
|
+
binding_val.into()
|
|
44344
|
+
};
|
|
44345
|
+
let config_core: xberg::ExtractionConfig = {
|
|
44346
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(config).map_err(|e| {
|
|
44347
|
+
magnus::Error::new(
|
|
44348
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44349
|
+
e.to_string(),
|
|
44350
|
+
)
|
|
44351
|
+
})?;
|
|
44352
|
+
binding_val.into()
|
|
44353
|
+
};
|
|
44354
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44355
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44356
|
+
.enable_all()
|
|
44357
|
+
.build()
|
|
44358
|
+
.map_err(|e| e.to_string())?;
|
|
44359
|
+
Ok(rt.block_on(async { xberg::extract_with_layout_pages(input_core, &config_core, pages).await }))
|
|
43573
44360
|
});
|
|
43574
44361
|
let result = async_result
|
|
43575
44362
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44363
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
44364
|
+
Ok(result.into())
|
|
44365
|
+
}
|
|
44366
|
+
|
|
44367
|
+
#[cfg(all(feature = "pdf", feature = "layout-detection"))]
|
|
44368
|
+
fn extract_with_layout_pages_async(
|
|
44369
|
+
input: magnus::Value,
|
|
44370
|
+
config: magnus::Value,
|
|
44371
|
+
pages: Vec<u32>,
|
|
44372
|
+
) -> Result<ExtractionResult, Error> {
|
|
44373
|
+
let input_core: xberg::ExtractInput = {
|
|
44374
|
+
let binding_val: ExtractInput = ExtractInput::try_convert(input).map_err(|e| {
|
|
44375
|
+
magnus::Error::new(
|
|
44376
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44377
|
+
e.to_string(),
|
|
44378
|
+
)
|
|
44379
|
+
})?;
|
|
44380
|
+
binding_val.into()
|
|
44381
|
+
};
|
|
44382
|
+
let config_core: xberg::ExtractionConfig = {
|
|
44383
|
+
let binding_val: ExtractionConfig = ExtractionConfig::try_convert(config).map_err(|e| {
|
|
44384
|
+
magnus::Error::new(
|
|
44385
|
+
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
44386
|
+
e.to_string(),
|
|
44387
|
+
)
|
|
44388
|
+
})?;
|
|
44389
|
+
binding_val.into()
|
|
44390
|
+
};
|
|
44391
|
+
let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
|
|
44392
|
+
let rt = tokio::runtime::Builder::new_current_thread()
|
|
44393
|
+
.enable_all()
|
|
44394
|
+
.build()
|
|
44395
|
+
.map_err(|e| e.to_string())?;
|
|
44396
|
+
Ok(rt.block_on(async { xberg::extract_with_layout_pages(input_core, &config_core, pages).await }))
|
|
44397
|
+
});
|
|
44398
|
+
let result = async_result
|
|
44399
|
+
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44400
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43576
44401
|
Ok(result.into())
|
|
43577
44402
|
}
|
|
43578
44403
|
|
|
@@ -43582,32 +44407,17 @@ fn find_unmarked_claims(markdown: String) -> Vec<String> {
|
|
|
43582
44407
|
}
|
|
43583
44408
|
|
|
43584
44409
|
fn list_document_extractors() -> Result<Vec<String>, Error> {
|
|
43585
|
-
let result = xberg::list_document_extractors().map_err(
|
|
43586
|
-
magnus::Error::new(
|
|
43587
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43588
|
-
e.to_string(),
|
|
43589
|
-
)
|
|
43590
|
-
})?;
|
|
44410
|
+
let result = xberg::list_document_extractors().map_err(alef_magnus_err)?;
|
|
43591
44411
|
Ok(result)
|
|
43592
44412
|
}
|
|
43593
44413
|
|
|
43594
44414
|
fn list_embedding_backends() -> Result<Vec<String>, Error> {
|
|
43595
|
-
let result = xberg::list_embedding_backends().map_err(
|
|
43596
|
-
magnus::Error::new(
|
|
43597
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43598
|
-
e.to_string(),
|
|
43599
|
-
)
|
|
43600
|
-
})?;
|
|
44415
|
+
let result = xberg::list_embedding_backends().map_err(alef_magnus_err)?;
|
|
43601
44416
|
Ok(result)
|
|
43602
44417
|
}
|
|
43603
44418
|
|
|
43604
44419
|
fn list_ocr_backend_capabilities() -> Result<Vec<OcrBackendCapabilities>, Error> {
|
|
43605
|
-
let result = xberg::list_ocr_backend_capabilities().map_err(
|
|
43606
|
-
magnus::Error::new(
|
|
43607
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43608
|
-
e.to_string(),
|
|
43609
|
-
)
|
|
43610
|
-
})?;
|
|
44420
|
+
let result = xberg::list_ocr_backend_capabilities().map_err(alef_magnus_err)?;
|
|
43611
44421
|
Ok(result.into_iter().map(Into::into).collect())
|
|
43612
44422
|
}
|
|
43613
44423
|
|
|
@@ -43627,52 +44437,27 @@ fn list_ocr_backend_capabilities_for(args: &[magnus::Value]) -> Result<Vec<OcrBa
|
|
|
43627
44437
|
}
|
|
43628
44438
|
_ => Default::default(),
|
|
43629
44439
|
};
|
|
43630
|
-
let result = xberg::list_ocr_backend_capabilities_for(&config_core).map_err(
|
|
43631
|
-
magnus::Error::new(
|
|
43632
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43633
|
-
e.to_string(),
|
|
43634
|
-
)
|
|
43635
|
-
})?;
|
|
44440
|
+
let result = xberg::list_ocr_backend_capabilities_for(&config_core).map_err(alef_magnus_err)?;
|
|
43636
44441
|
Ok(result.into_iter().map(Into::into).collect())
|
|
43637
44442
|
}
|
|
43638
44443
|
|
|
43639
44444
|
fn list_ocr_backends() -> Result<Vec<String>, Error> {
|
|
43640
|
-
let result = xberg::list_ocr_backends().map_err(
|
|
43641
|
-
magnus::Error::new(
|
|
43642
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43643
|
-
e.to_string(),
|
|
43644
|
-
)
|
|
43645
|
-
})?;
|
|
44445
|
+
let result = xberg::list_ocr_backends().map_err(alef_magnus_err)?;
|
|
43646
44446
|
Ok(result)
|
|
43647
44447
|
}
|
|
43648
44448
|
|
|
43649
44449
|
fn list_post_processors() -> Result<Vec<String>, Error> {
|
|
43650
|
-
let result = xberg::list_post_processors().map_err(
|
|
43651
|
-
magnus::Error::new(
|
|
43652
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43653
|
-
e.to_string(),
|
|
43654
|
-
)
|
|
43655
|
-
})?;
|
|
44450
|
+
let result = xberg::list_post_processors().map_err(alef_magnus_err)?;
|
|
43656
44451
|
Ok(result)
|
|
43657
44452
|
}
|
|
43658
44453
|
|
|
43659
44454
|
fn list_renderers() -> Result<Vec<String>, Error> {
|
|
43660
|
-
let result = xberg::list_renderers().map_err(
|
|
43661
|
-
magnus::Error::new(
|
|
43662
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43663
|
-
e.to_string(),
|
|
43664
|
-
)
|
|
43665
|
-
})?;
|
|
44455
|
+
let result = xberg::list_renderers().map_err(alef_magnus_err)?;
|
|
43666
44456
|
Ok(result)
|
|
43667
44457
|
}
|
|
43668
44458
|
|
|
43669
44459
|
fn list_reranker_backends() -> Result<Vec<String>, Error> {
|
|
43670
|
-
let result = xberg::list_reranker_backends().map_err(
|
|
43671
|
-
magnus::Error::new(
|
|
43672
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43673
|
-
e.to_string(),
|
|
43674
|
-
)
|
|
43675
|
-
})?;
|
|
44460
|
+
let result = xberg::list_reranker_backends().map_err(alef_magnus_err)?;
|
|
43676
44461
|
Ok(result)
|
|
43677
44462
|
}
|
|
43678
44463
|
|
|
@@ -43681,22 +44466,12 @@ fn list_supported_formats() -> Vec<SupportedFormat> {
|
|
|
43681
44466
|
}
|
|
43682
44467
|
|
|
43683
44468
|
fn list_tokenizer_backends() -> Result<Vec<String>, Error> {
|
|
43684
|
-
let result = xberg::list_tokenizer_backends().map_err(
|
|
43685
|
-
magnus::Error::new(
|
|
43686
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43687
|
-
e.to_string(),
|
|
43688
|
-
)
|
|
43689
|
-
})?;
|
|
44469
|
+
let result = xberg::list_tokenizer_backends().map_err(alef_magnus_err)?;
|
|
43690
44470
|
Ok(result)
|
|
43691
44471
|
}
|
|
43692
44472
|
|
|
43693
44473
|
fn list_validators() -> Result<Vec<String>, Error> {
|
|
43694
|
-
let result = xberg::list_validators().map_err(
|
|
43695
|
-
magnus::Error::new(
|
|
43696
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43697
|
-
e.to_string(),
|
|
43698
|
-
)
|
|
43699
|
-
})?;
|
|
44474
|
+
let result = xberg::list_validators().map_err(alef_magnus_err)?;
|
|
43700
44475
|
Ok(result)
|
|
43701
44476
|
}
|
|
43702
44477
|
|
|
@@ -43724,11 +44499,11 @@ fn map_url(args: &[magnus::Value]) -> Result<MapResult, Error> {
|
|
|
43724
44499
|
.enable_all()
|
|
43725
44500
|
.build()
|
|
43726
44501
|
.map_err(|e| e.to_string())?;
|
|
43727
|
-
rt.block_on(async { xberg::map_url(&uri, &config_core).await })
|
|
43728
|
-
.map_err(|e| e.to_string())
|
|
44502
|
+
Ok(rt.block_on(async { xberg::map_url(&uri, &config_core).await }))
|
|
43729
44503
|
});
|
|
43730
44504
|
let result = async_result
|
|
43731
44505
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44506
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43732
44507
|
Ok(result.into())
|
|
43733
44508
|
}
|
|
43734
44509
|
|
|
@@ -43756,11 +44531,11 @@ fn map_url_async(args: &[magnus::Value]) -> Result<MapResult, Error> {
|
|
|
43756
44531
|
.enable_all()
|
|
43757
44532
|
.build()
|
|
43758
44533
|
.map_err(|e| e.to_string())?;
|
|
43759
|
-
rt.block_on(async { xberg::map_url(&uri, &config_core).await })
|
|
43760
|
-
.map_err(|e| e.to_string())
|
|
44534
|
+
Ok(rt.block_on(async { xberg::map_url(&uri, &config_core).await }))
|
|
43761
44535
|
});
|
|
43762
44536
|
let result = async_result
|
|
43763
44537
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44538
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43764
44539
|
Ok(result.into())
|
|
43765
44540
|
}
|
|
43766
44541
|
|
|
@@ -43812,12 +44587,7 @@ fn max_sim_score(query: magnus::Value, doc: magnus::Value) -> Result<f64, Error>
|
|
|
43812
44587
|
}
|
|
43813
44588
|
|
|
43814
44589
|
fn ocr_backend_supports_language(backend: String, language: String) -> Result<bool, Error> {
|
|
43815
|
-
let result = xberg::ocr_backend_supports_language(&backend, &language).map_err(
|
|
43816
|
-
magnus::Error::new(
|
|
43817
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43818
|
-
e.to_string(),
|
|
43819
|
-
)
|
|
43820
|
-
})?;
|
|
44590
|
+
let result = xberg::ocr_backend_supports_language(&backend, &language).map_err(alef_magnus_err)?;
|
|
43821
44591
|
Ok(result)
|
|
43822
44592
|
}
|
|
43823
44593
|
|
|
@@ -43839,12 +44609,8 @@ fn ocr_backend_supports_language_for(args: &[magnus::Value]) -> Result<bool, Err
|
|
|
43839
44609
|
}
|
|
43840
44610
|
_ => Default::default(),
|
|
43841
44611
|
};
|
|
43842
|
-
let result =
|
|
43843
|
-
|
|
43844
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43845
|
-
e.to_string(),
|
|
43846
|
-
)
|
|
43847
|
-
})?;
|
|
44612
|
+
let result =
|
|
44613
|
+
xberg::ocr_backend_supports_language_for(&backend, &language, &config_core).map_err(alef_magnus_err)?;
|
|
43848
44614
|
Ok(result)
|
|
43849
44615
|
}
|
|
43850
44616
|
|
|
@@ -43855,20 +44621,12 @@ fn pdf_page_count(args: &[magnus::Value]) -> Result<usize, Error> {
|
|
|
43855
44621
|
|
|
43856
44622
|
let (password,) = args.optional;
|
|
43857
44623
|
|
|
43858
|
-
let password: Option<String> = password
|
|
43859
|
-
if v.is_nil()
|
|
43860
|
-
|
|
43861
|
-
|
|
43862
|
-
Some(String::try_convert(v).unwrap_or_default())
|
|
43863
|
-
}
|
|
43864
|
-
});
|
|
44624
|
+
let password: Option<String> = match password {
|
|
44625
|
+
Some(v) if !v.is_nil() => Some(String::try_convert(v)?),
|
|
44626
|
+
_ => None,
|
|
44627
|
+
};
|
|
43865
44628
|
|
|
43866
|
-
let result = xberg::pdf_page_count(&pdf_bytes, password.as_deref()).map_err(
|
|
43867
|
-
magnus::Error::new(
|
|
43868
|
-
unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
|
|
43869
|
-
e.to_string(),
|
|
43870
|
-
)
|
|
43871
|
-
})?;
|
|
44629
|
+
let result = xberg::pdf_page_count(&pdf_bytes, password.as_deref()).map_err(alef_magnus_err)?;
|
|
43872
44630
|
Ok(result)
|
|
43873
44631
|
}
|
|
43874
44632
|
|
|
@@ -43876,7 +44634,7 @@ fn pdf_page_count(args: &[magnus::Value]) -> Result<usize, Error> {
|
|
|
43876
44634
|
fn redact_external(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
43877
44635
|
let args = magnus::scan_args::scan_args::<
|
|
43878
44636
|
(magnus::Value, magnus::Value, String),
|
|
43879
|
-
(Option<magnus::Value>, Option<
|
|
44637
|
+
(Option<magnus::Value>, Option<magnus::Value>),
|
|
43880
44638
|
(),
|
|
43881
44639
|
(),
|
|
43882
44640
|
(),
|
|
@@ -43886,13 +44644,15 @@ fn redact_external(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
|
43886
44644
|
|
|
43887
44645
|
let (offset_encoding, max_findings) = args.optional;
|
|
43888
44646
|
|
|
43889
|
-
let offset_encoding: Option<String> = offset_encoding
|
|
43890
|
-
if v.is_nil()
|
|
43891
|
-
|
|
43892
|
-
|
|
43893
|
-
|
|
43894
|
-
|
|
43895
|
-
|
|
44647
|
+
let offset_encoding: Option<String> = match offset_encoding {
|
|
44648
|
+
Some(v) if !v.is_nil() => Some(String::try_convert(v)?),
|
|
44649
|
+
_ => None,
|
|
44650
|
+
};
|
|
44651
|
+
|
|
44652
|
+
let max_findings: Option<u32> = match max_findings {
|
|
44653
|
+
Some(v) if !v.is_nil() => Some(u32::try_convert(v)?),
|
|
44654
|
+
_ => None,
|
|
44655
|
+
};
|
|
43896
44656
|
|
|
43897
44657
|
let document: xberg::ExtractedDocument = {
|
|
43898
44658
|
let binding_val: ExtractedDocument = ExtractedDocument::try_convert(document)
|
|
@@ -43909,7 +44669,7 @@ fn redact_external(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
|
43909
44669
|
.enable_all()
|
|
43910
44670
|
.build()
|
|
43911
44671
|
.map_err(|e| e.to_string())?;
|
|
43912
|
-
rt.block_on(async {
|
|
44672
|
+
Ok(rt.block_on(async {
|
|
43913
44673
|
xberg::redact_external(
|
|
43914
44674
|
document.into(),
|
|
43915
44675
|
config.into(),
|
|
@@ -43918,11 +44678,11 @@ fn redact_external(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
|
43918
44678
|
max_findings,
|
|
43919
44679
|
)
|
|
43920
44680
|
.await
|
|
43921
|
-
})
|
|
43922
|
-
.map_err(|e| e.to_string())
|
|
44681
|
+
}))
|
|
43923
44682
|
});
|
|
43924
44683
|
let result = async_result
|
|
43925
44684
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44685
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43926
44686
|
Ok(result.into())
|
|
43927
44687
|
}
|
|
43928
44688
|
|
|
@@ -43930,7 +44690,7 @@ fn redact_external(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
|
43930
44690
|
fn redact_external_async(args: &[magnus::Value]) -> Result<ExtractedDocument, Error> {
|
|
43931
44691
|
let args = magnus::scan_args::scan_args::<
|
|
43932
44692
|
(magnus::Value, magnus::Value, String),
|
|
43933
|
-
(Option<magnus::Value>, Option<
|
|
44693
|
+
(Option<magnus::Value>, Option<magnus::Value>),
|
|
43934
44694
|
(),
|
|
43935
44695
|
(),
|
|
43936
44696
|
(),
|
|
@@ -43940,13 +44700,15 @@ fn redact_external_async(args: &[magnus::Value]) -> Result<ExtractedDocument, Er
|
|
|
43940
44700
|
|
|
43941
44701
|
let (offset_encoding, max_findings) = args.optional;
|
|
43942
44702
|
|
|
43943
|
-
let offset_encoding: Option<String> = offset_encoding
|
|
43944
|
-
if v.is_nil()
|
|
43945
|
-
|
|
43946
|
-
|
|
43947
|
-
|
|
43948
|
-
|
|
43949
|
-
|
|
44703
|
+
let offset_encoding: Option<String> = match offset_encoding {
|
|
44704
|
+
Some(v) if !v.is_nil() => Some(String::try_convert(v)?),
|
|
44705
|
+
_ => None,
|
|
44706
|
+
};
|
|
44707
|
+
|
|
44708
|
+
let max_findings: Option<u32> = match max_findings {
|
|
44709
|
+
Some(v) if !v.is_nil() => Some(u32::try_convert(v)?),
|
|
44710
|
+
_ => None,
|
|
44711
|
+
};
|
|
43950
44712
|
|
|
43951
44713
|
let document: xberg::ExtractedDocument = {
|
|
43952
44714
|
let binding_val: ExtractedDocument = ExtractedDocument::try_convert(document)
|
|
@@ -43963,7 +44725,7 @@ fn redact_external_async(args: &[magnus::Value]) -> Result<ExtractedDocument, Er
|
|
|
43963
44725
|
.enable_all()
|
|
43964
44726
|
.build()
|
|
43965
44727
|
.map_err(|e| e.to_string())?;
|
|
43966
|
-
rt.block_on(async {
|
|
44728
|
+
Ok(rt.block_on(async {
|
|
43967
44729
|
xberg::redact_external(
|
|
43968
44730
|
document.into(),
|
|
43969
44731
|
config.into(),
|
|
@@ -43972,11 +44734,11 @@ fn redact_external_async(args: &[magnus::Value]) -> Result<ExtractedDocument, Er
|
|
|
43972
44734
|
max_findings,
|
|
43973
44735
|
)
|
|
43974
44736
|
.await
|
|
43975
|
-
})
|
|
43976
|
-
.map_err(|e| e.to_string())
|
|
44737
|
+
}))
|
|
43977
44738
|
});
|
|
43978
44739
|
let result = async_result
|
|
43979
44740
|
.map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
|
|
44741
|
+
let result = result.map_err(alef_magnus_err)?;
|
|
43980
44742
|
Ok(result.into())
|
|
43981
44743
|
}
|
|
43982
44744
|
|
|
@@ -44200,10 +44962,15 @@ impl xberg::plugins::Plugin for RbOcrBackendBridge {
|
|
|
44200
44962
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
44201
44963
|
Ok(v) => v,
|
|
44202
44964
|
Err(e) => {
|
|
44203
|
-
return Err(
|
|
44204
|
-
"Ruby method 'initialize' failed: {}",
|
|
44205
|
-
|
|
44206
|
-
|
|
44965
|
+
return Err(
|
|
44966
|
+
match ("OcrBackend", None, format!("Ruby method 'initialize' failed: {}", e)) {
|
|
44967
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
44968
|
+
message,
|
|
44969
|
+
source: Some(source),
|
|
44970
|
+
},
|
|
44971
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
44972
|
+
},
|
|
44973
|
+
);
|
|
44207
44974
|
}
|
|
44208
44975
|
};
|
|
44209
44976
|
let _ = val;
|
|
@@ -44213,10 +44980,19 @@ impl xberg::plugins::Plugin for RbOcrBackendBridge {
|
|
|
44213
44980
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
44214
44981
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
44215
44982
|
Ok(result) => result,
|
|
44216
|
-
Err(error) => Err(
|
|
44217
|
-
|
|
44218
|
-
|
|
44219
|
-
|
|
44983
|
+
Err(error) => Err(
|
|
44984
|
+
match (
|
|
44985
|
+
"OcrBackend",
|
|
44986
|
+
None,
|
|
44987
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
44988
|
+
) {
|
|
44989
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
44990
|
+
message,
|
|
44991
|
+
source: Some(source),
|
|
44992
|
+
},
|
|
44993
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
44994
|
+
},
|
|
44995
|
+
),
|
|
44220
44996
|
},
|
|
44221
44997
|
}
|
|
44222
44998
|
}
|
|
@@ -44229,10 +45005,15 @@ impl xberg::plugins::Plugin for RbOcrBackendBridge {
|
|
|
44229
45005
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
44230
45006
|
Ok(v) => v,
|
|
44231
45007
|
Err(e) => {
|
|
44232
|
-
return Err(
|
|
44233
|
-
"Ruby method 'shutdown' failed: {}",
|
|
44234
|
-
|
|
44235
|
-
|
|
45008
|
+
return Err(
|
|
45009
|
+
match ("OcrBackend", None, format!("Ruby method 'shutdown' failed: {}", e)) {
|
|
45010
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45011
|
+
message,
|
|
45012
|
+
source: Some(source),
|
|
45013
|
+
},
|
|
45014
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45015
|
+
},
|
|
45016
|
+
);
|
|
44236
45017
|
}
|
|
44237
45018
|
};
|
|
44238
45019
|
let _ = val;
|
|
@@ -44242,10 +45023,19 @@ impl xberg::plugins::Plugin for RbOcrBackendBridge {
|
|
|
44242
45023
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
44243
45024
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
44244
45025
|
Ok(result) => result,
|
|
44245
|
-
Err(error) => Err(
|
|
44246
|
-
|
|
44247
|
-
|
|
44248
|
-
|
|
45026
|
+
Err(error) => Err(
|
|
45027
|
+
match (
|
|
45028
|
+
"OcrBackend",
|
|
45029
|
+
None,
|
|
45030
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
45031
|
+
) {
|
|
45032
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45033
|
+
message,
|
|
45034
|
+
source: Some(source),
|
|
45035
|
+
},
|
|
45036
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45037
|
+
},
|
|
45038
|
+
),
|
|
44249
45039
|
},
|
|
44250
45040
|
}
|
|
44251
45041
|
}
|
|
@@ -44277,29 +45067,65 @@ impl xberg::OcrBackend for RbOcrBackendBridge {
|
|
|
44277
45067
|
) {
|
|
44278
45068
|
Ok(v) => v,
|
|
44279
45069
|
Err(e) => {
|
|
44280
|
-
return Err(
|
|
44281
|
-
"Ruby method 'process_image' failed: {}",
|
|
44282
|
-
|
|
44283
|
-
|
|
45070
|
+
return Err(
|
|
45071
|
+
match ("OcrBackend", None, format!("Ruby method 'process_image' failed: {}", e)) {
|
|
45072
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45073
|
+
message,
|
|
45074
|
+
source: Some(source),
|
|
45075
|
+
},
|
|
45076
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45077
|
+
},
|
|
45078
|
+
);
|
|
44284
45079
|
}
|
|
44285
45080
|
}; // Native-object return: the binding struct's `TryConvert` accepts the host's native wrapped
|
|
44286
45081
|
// object (and still a Hash/JSON via `to_json`); `From<ExtractedDocument>` yields core.
|
|
44287
45082
|
<ExtractedDocument as magnus::TryConvert>::try_convert(val)
|
|
44288
45083
|
.map(Into::into)
|
|
44289
45084
|
.map_err(|e| {
|
|
44290
|
-
|
|
45085
|
+
match (
|
|
45086
|
+
"OcrBackend",
|
|
45087
|
+
None,
|
|
45088
|
+
format!("Failed to convert Ruby 'process_image' return value: {}", e),
|
|
45089
|
+
) {
|
|
45090
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45091
|
+
message,
|
|
45092
|
+
source: Some(source),
|
|
45093
|
+
},
|
|
45094
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45095
|
+
}
|
|
44291
45096
|
})
|
|
44292
45097
|
};
|
|
44293
45098
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
44294
45099
|
Ok(Ok(result)) => result,
|
|
44295
|
-
Ok(Err(error)) => Err(
|
|
44296
|
-
|
|
44297
|
-
|
|
44298
|
-
|
|
44299
|
-
|
|
44300
|
-
|
|
44301
|
-
|
|
44302
|
-
|
|
45100
|
+
Ok(Err(error)) => Err(
|
|
45101
|
+
match (
|
|
45102
|
+
"OcrBackend",
|
|
45103
|
+
None,
|
|
45104
|
+
format!("Ruby runtime dispatcher failed for method 'process_image': {}", error),
|
|
45105
|
+
) {
|
|
45106
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45107
|
+
message,
|
|
45108
|
+
source: Some(source),
|
|
45109
|
+
},
|
|
45110
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45111
|
+
},
|
|
45112
|
+
),
|
|
45113
|
+
Err(error) => Err(
|
|
45114
|
+
match (
|
|
45115
|
+
"OcrBackend",
|
|
45116
|
+
None,
|
|
45117
|
+
format!(
|
|
45118
|
+
"Ruby runtime dispatcher task failed for method 'process_image': {}",
|
|
45119
|
+
error
|
|
45120
|
+
),
|
|
45121
|
+
) {
|
|
45122
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45123
|
+
message,
|
|
45124
|
+
source: Some(source),
|
|
45125
|
+
},
|
|
45126
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45127
|
+
},
|
|
45128
|
+
),
|
|
44303
45129
|
}
|
|
44304
45130
|
}
|
|
44305
45131
|
|
|
@@ -44336,32 +45162,72 @@ impl xberg::OcrBackend for RbOcrBackendBridge {
|
|
|
44336
45162
|
) {
|
|
44337
45163
|
Ok(v) => v,
|
|
44338
45164
|
Err(e) => {
|
|
44339
|
-
return Err(
|
|
44340
|
-
|
|
44341
|
-
|
|
44342
|
-
|
|
45165
|
+
return Err(
|
|
45166
|
+
match (
|
|
45167
|
+
"OcrBackend",
|
|
45168
|
+
None,
|
|
45169
|
+
format!("Ruby method 'process_image_file' failed: {}", e),
|
|
45170
|
+
) {
|
|
45171
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45172
|
+
message,
|
|
45173
|
+
source: Some(source),
|
|
45174
|
+
},
|
|
45175
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45176
|
+
},
|
|
45177
|
+
);
|
|
44343
45178
|
}
|
|
44344
45179
|
}; // Native-object return: the binding struct's `TryConvert` accepts the host's native wrapped
|
|
44345
45180
|
// object (and still a Hash/JSON via `to_json`); `From<ExtractedDocument>` yields core.
|
|
44346
45181
|
<ExtractedDocument as magnus::TryConvert>::try_convert(val)
|
|
44347
45182
|
.map(Into::into)
|
|
44348
45183
|
.map_err(|e| {
|
|
44349
|
-
|
|
44350
|
-
"
|
|
44351
|
-
|
|
44352
|
-
|
|
45184
|
+
match (
|
|
45185
|
+
"OcrBackend",
|
|
45186
|
+
None,
|
|
45187
|
+
format!("Failed to convert Ruby 'process_image_file' return value: {}", e),
|
|
45188
|
+
) {
|
|
45189
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45190
|
+
message,
|
|
45191
|
+
source: Some(source),
|
|
45192
|
+
},
|
|
45193
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45194
|
+
}
|
|
44353
45195
|
})
|
|
44354
45196
|
};
|
|
44355
45197
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
44356
45198
|
Ok(Ok(result)) => result,
|
|
44357
|
-
Ok(Err(error)) => Err(
|
|
44358
|
-
|
|
44359
|
-
|
|
44360
|
-
|
|
44361
|
-
|
|
44362
|
-
|
|
44363
|
-
|
|
44364
|
-
|
|
45199
|
+
Ok(Err(error)) => Err(
|
|
45200
|
+
match (
|
|
45201
|
+
"OcrBackend",
|
|
45202
|
+
None,
|
|
45203
|
+
format!(
|
|
45204
|
+
"Ruby runtime dispatcher failed for method 'process_image_file': {}",
|
|
45205
|
+
error
|
|
45206
|
+
),
|
|
45207
|
+
) {
|
|
45208
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45209
|
+
message,
|
|
45210
|
+
source: Some(source),
|
|
45211
|
+
},
|
|
45212
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45213
|
+
},
|
|
45214
|
+
),
|
|
45215
|
+
Err(error) => Err(
|
|
45216
|
+
match (
|
|
45217
|
+
"OcrBackend",
|
|
45218
|
+
None,
|
|
45219
|
+
format!(
|
|
45220
|
+
"Ruby runtime dispatcher task failed for method 'process_image_file': {}",
|
|
45221
|
+
error
|
|
45222
|
+
),
|
|
45223
|
+
) {
|
|
45224
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45225
|
+
message,
|
|
45226
|
+
source: Some(source),
|
|
45227
|
+
},
|
|
45228
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45229
|
+
},
|
|
45230
|
+
),
|
|
44365
45231
|
}
|
|
44366
45232
|
}
|
|
44367
45233
|
|
|
@@ -44767,29 +45633,72 @@ impl xberg::OcrBackend for RbOcrBackendBridge {
|
|
|
44767
45633
|
) {
|
|
44768
45634
|
Ok(v) => v,
|
|
44769
45635
|
Err(e) => {
|
|
44770
|
-
return Err(
|
|
44771
|
-
|
|
44772
|
-
|
|
44773
|
-
|
|
45636
|
+
return Err(
|
|
45637
|
+
match (
|
|
45638
|
+
"OcrBackend",
|
|
45639
|
+
None,
|
|
45640
|
+
format!("Ruby method 'process_document' failed: {}", e),
|
|
45641
|
+
) {
|
|
45642
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45643
|
+
message,
|
|
45644
|
+
source: Some(source),
|
|
45645
|
+
},
|
|
45646
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45647
|
+
},
|
|
45648
|
+
);
|
|
44774
45649
|
}
|
|
44775
45650
|
}; // Native-object return: the binding struct's `TryConvert` accepts the host's native wrapped
|
|
44776
45651
|
// object (and still a Hash/JSON via `to_json`); `From<ExtractedDocument>` yields core.
|
|
44777
45652
|
<ExtractedDocument as magnus::TryConvert>::try_convert(val)
|
|
44778
45653
|
.map(Into::into)
|
|
44779
45654
|
.map_err(|e| {
|
|
44780
|
-
|
|
45655
|
+
match (
|
|
45656
|
+
"OcrBackend",
|
|
45657
|
+
None,
|
|
45658
|
+
format!("Failed to convert Ruby 'process_document' return value: {}", e),
|
|
45659
|
+
) {
|
|
45660
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45661
|
+
message,
|
|
45662
|
+
source: Some(source),
|
|
45663
|
+
},
|
|
45664
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45665
|
+
}
|
|
44781
45666
|
})
|
|
44782
45667
|
};
|
|
44783
45668
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
44784
45669
|
Ok(Ok(result)) => result,
|
|
44785
|
-
Ok(Err(error)) => Err(
|
|
44786
|
-
|
|
44787
|
-
|
|
44788
|
-
|
|
44789
|
-
|
|
44790
|
-
|
|
44791
|
-
|
|
44792
|
-
|
|
45670
|
+
Ok(Err(error)) => Err(
|
|
45671
|
+
match (
|
|
45672
|
+
"OcrBackend",
|
|
45673
|
+
None,
|
|
45674
|
+
format!(
|
|
45675
|
+
"Ruby runtime dispatcher failed for method 'process_document': {}",
|
|
45676
|
+
error
|
|
45677
|
+
),
|
|
45678
|
+
) {
|
|
45679
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45680
|
+
message,
|
|
45681
|
+
source: Some(source),
|
|
45682
|
+
},
|
|
45683
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45684
|
+
},
|
|
45685
|
+
),
|
|
45686
|
+
Err(error) => Err(
|
|
45687
|
+
match (
|
|
45688
|
+
"OcrBackend",
|
|
45689
|
+
None,
|
|
45690
|
+
format!(
|
|
45691
|
+
"Ruby runtime dispatcher task failed for method 'process_document': {}",
|
|
45692
|
+
error
|
|
45693
|
+
),
|
|
45694
|
+
) {
|
|
45695
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
45696
|
+
message,
|
|
45697
|
+
source: Some(source),
|
|
45698
|
+
},
|
|
45699
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
45700
|
+
},
|
|
45701
|
+
),
|
|
44793
45702
|
}
|
|
44794
45703
|
}
|
|
44795
45704
|
}
|
|
@@ -45756,10 +46665,15 @@ impl xberg::plugins::Plugin for RbPostProcessorBridge {
|
|
|
45756
46665
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
45757
46666
|
Ok(v) => v,
|
|
45758
46667
|
Err(e) => {
|
|
45759
|
-
return Err(
|
|
45760
|
-
"Ruby method 'initialize' failed: {}",
|
|
45761
|
-
|
|
45762
|
-
|
|
46668
|
+
return Err(
|
|
46669
|
+
match ("PostProcessor", None, format!("Ruby method 'initialize' failed: {}", e)) {
|
|
46670
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46671
|
+
message,
|
|
46672
|
+
source: Some(source),
|
|
46673
|
+
},
|
|
46674
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46675
|
+
},
|
|
46676
|
+
);
|
|
45763
46677
|
}
|
|
45764
46678
|
};
|
|
45765
46679
|
let _ = val;
|
|
@@ -45769,10 +46683,19 @@ impl xberg::plugins::Plugin for RbPostProcessorBridge {
|
|
|
45769
46683
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
45770
46684
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
45771
46685
|
Ok(result) => result,
|
|
45772
|
-
Err(error) => Err(
|
|
45773
|
-
|
|
45774
|
-
|
|
45775
|
-
|
|
46686
|
+
Err(error) => Err(
|
|
46687
|
+
match (
|
|
46688
|
+
"PostProcessor",
|
|
46689
|
+
None,
|
|
46690
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
46691
|
+
) {
|
|
46692
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46693
|
+
message,
|
|
46694
|
+
source: Some(source),
|
|
46695
|
+
},
|
|
46696
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46697
|
+
},
|
|
46698
|
+
),
|
|
45776
46699
|
},
|
|
45777
46700
|
}
|
|
45778
46701
|
}
|
|
@@ -45785,10 +46708,15 @@ impl xberg::plugins::Plugin for RbPostProcessorBridge {
|
|
|
45785
46708
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
45786
46709
|
Ok(v) => v,
|
|
45787
46710
|
Err(e) => {
|
|
45788
|
-
return Err(
|
|
45789
|
-
"Ruby method 'shutdown' failed: {}",
|
|
45790
|
-
|
|
45791
|
-
|
|
46711
|
+
return Err(
|
|
46712
|
+
match ("PostProcessor", None, format!("Ruby method 'shutdown' failed: {}", e)) {
|
|
46713
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46714
|
+
message,
|
|
46715
|
+
source: Some(source),
|
|
46716
|
+
},
|
|
46717
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46718
|
+
},
|
|
46719
|
+
);
|
|
45792
46720
|
}
|
|
45793
46721
|
};
|
|
45794
46722
|
let _ = val;
|
|
@@ -45798,10 +46726,19 @@ impl xberg::plugins::Plugin for RbPostProcessorBridge {
|
|
|
45798
46726
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
45799
46727
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
45800
46728
|
Ok(result) => result,
|
|
45801
|
-
Err(error) => Err(
|
|
45802
|
-
|
|
45803
|
-
|
|
45804
|
-
|
|
46729
|
+
Err(error) => Err(
|
|
46730
|
+
match (
|
|
46731
|
+
"PostProcessor",
|
|
46732
|
+
None,
|
|
46733
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
46734
|
+
) {
|
|
46735
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46736
|
+
message,
|
|
46737
|
+
source: Some(source),
|
|
46738
|
+
},
|
|
46739
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46740
|
+
},
|
|
46741
|
+
),
|
|
45805
46742
|
},
|
|
45806
46743
|
}
|
|
45807
46744
|
}
|
|
@@ -45833,7 +46770,15 @@ impl xberg::PostProcessor for RbPostProcessorBridge {
|
|
|
45833
46770
|
) {
|
|
45834
46771
|
Ok(v) => v,
|
|
45835
46772
|
Err(e) => {
|
|
45836
|
-
return Err(
|
|
46773
|
+
return Err(
|
|
46774
|
+
match ("PostProcessor", None, format!("Ruby method 'process' failed: {}", e)) {
|
|
46775
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46776
|
+
message,
|
|
46777
|
+
source: Some(source),
|
|
46778
|
+
},
|
|
46779
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46780
|
+
},
|
|
46781
|
+
);
|
|
45837
46782
|
}
|
|
45838
46783
|
};
|
|
45839
46784
|
let _ = val;
|
|
@@ -45841,14 +46786,32 @@ impl xberg::PostProcessor for RbPostProcessorBridge {
|
|
|
45841
46786
|
};
|
|
45842
46787
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
45843
46788
|
Ok(Ok(result)) => result,
|
|
45844
|
-
Ok(Err(error)) => Err(
|
|
45845
|
-
|
|
45846
|
-
|
|
45847
|
-
|
|
45848
|
-
|
|
45849
|
-
|
|
45850
|
-
|
|
45851
|
-
|
|
46789
|
+
Ok(Err(error)) => Err(
|
|
46790
|
+
match (
|
|
46791
|
+
"PostProcessor",
|
|
46792
|
+
None,
|
|
46793
|
+
format!("Ruby runtime dispatcher failed for method 'process': {}", error),
|
|
46794
|
+
) {
|
|
46795
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46796
|
+
message,
|
|
46797
|
+
source: Some(source),
|
|
46798
|
+
},
|
|
46799
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46800
|
+
},
|
|
46801
|
+
),
|
|
46802
|
+
Err(error) => Err(
|
|
46803
|
+
match (
|
|
46804
|
+
"PostProcessor",
|
|
46805
|
+
None,
|
|
46806
|
+
format!("Ruby runtime dispatcher task failed for method 'process': {}", error),
|
|
46807
|
+
) {
|
|
46808
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
46809
|
+
message,
|
|
46810
|
+
source: Some(source),
|
|
46811
|
+
},
|
|
46812
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
46813
|
+
},
|
|
46814
|
+
),
|
|
45852
46815
|
}
|
|
45853
46816
|
}
|
|
45854
46817
|
|
|
@@ -46357,10 +47320,15 @@ impl xberg::plugins::Plugin for RbValidatorBridge {
|
|
|
46357
47320
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
46358
47321
|
Ok(v) => v,
|
|
46359
47322
|
Err(e) => {
|
|
46360
|
-
return Err(
|
|
46361
|
-
"Ruby method 'initialize' failed: {}",
|
|
46362
|
-
|
|
46363
|
-
|
|
47323
|
+
return Err(
|
|
47324
|
+
match ("Validator", None, format!("Ruby method 'initialize' failed: {}", e)) {
|
|
47325
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47326
|
+
message,
|
|
47327
|
+
source: Some(source),
|
|
47328
|
+
},
|
|
47329
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47330
|
+
},
|
|
47331
|
+
);
|
|
46364
47332
|
}
|
|
46365
47333
|
};
|
|
46366
47334
|
let _ = val;
|
|
@@ -46370,10 +47338,19 @@ impl xberg::plugins::Plugin for RbValidatorBridge {
|
|
|
46370
47338
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
46371
47339
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
46372
47340
|
Ok(result) => result,
|
|
46373
|
-
Err(error) => Err(
|
|
46374
|
-
|
|
46375
|
-
|
|
46376
|
-
|
|
47341
|
+
Err(error) => Err(
|
|
47342
|
+
match (
|
|
47343
|
+
"Validator",
|
|
47344
|
+
None,
|
|
47345
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
47346
|
+
) {
|
|
47347
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47348
|
+
message,
|
|
47349
|
+
source: Some(source),
|
|
47350
|
+
},
|
|
47351
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47352
|
+
},
|
|
47353
|
+
),
|
|
46377
47354
|
},
|
|
46378
47355
|
}
|
|
46379
47356
|
}
|
|
@@ -46386,10 +47363,15 @@ impl xberg::plugins::Plugin for RbValidatorBridge {
|
|
|
46386
47363
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
46387
47364
|
Ok(v) => v,
|
|
46388
47365
|
Err(e) => {
|
|
46389
|
-
return Err(
|
|
46390
|
-
"Ruby method 'shutdown' failed: {}",
|
|
46391
|
-
|
|
46392
|
-
|
|
47366
|
+
return Err(
|
|
47367
|
+
match ("Validator", None, format!("Ruby method 'shutdown' failed: {}", e)) {
|
|
47368
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47369
|
+
message,
|
|
47370
|
+
source: Some(source),
|
|
47371
|
+
},
|
|
47372
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47373
|
+
},
|
|
47374
|
+
);
|
|
46393
47375
|
}
|
|
46394
47376
|
};
|
|
46395
47377
|
let _ = val;
|
|
@@ -46399,10 +47381,19 @@ impl xberg::plugins::Plugin for RbValidatorBridge {
|
|
|
46399
47381
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
46400
47382
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
46401
47383
|
Ok(result) => result,
|
|
46402
|
-
Err(error) => Err(
|
|
46403
|
-
|
|
46404
|
-
|
|
46405
|
-
|
|
47384
|
+
Err(error) => Err(
|
|
47385
|
+
match (
|
|
47386
|
+
"Validator",
|
|
47387
|
+
None,
|
|
47388
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
47389
|
+
) {
|
|
47390
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47391
|
+
message,
|
|
47392
|
+
source: Some(source),
|
|
47393
|
+
},
|
|
47394
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47395
|
+
},
|
|
47396
|
+
),
|
|
46406
47397
|
},
|
|
46407
47398
|
}
|
|
46408
47399
|
}
|
|
@@ -46434,10 +47425,15 @@ impl xberg::Validator for RbValidatorBridge {
|
|
|
46434
47425
|
) {
|
|
46435
47426
|
Ok(v) => v,
|
|
46436
47427
|
Err(e) => {
|
|
46437
|
-
return Err(
|
|
46438
|
-
"Ruby method 'validate' failed: {}",
|
|
46439
|
-
|
|
46440
|
-
|
|
47428
|
+
return Err(
|
|
47429
|
+
match ("Validator", None, format!("Ruby method 'validate' failed: {}", e)) {
|
|
47430
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47431
|
+
message,
|
|
47432
|
+
source: Some(source),
|
|
47433
|
+
},
|
|
47434
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47435
|
+
},
|
|
47436
|
+
);
|
|
46441
47437
|
}
|
|
46442
47438
|
};
|
|
46443
47439
|
let _ = val;
|
|
@@ -46445,14 +47441,32 @@ impl xberg::Validator for RbValidatorBridge {
|
|
|
46445
47441
|
};
|
|
46446
47442
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
46447
47443
|
Ok(Ok(result)) => result,
|
|
46448
|
-
Ok(Err(error)) => Err(
|
|
46449
|
-
|
|
46450
|
-
|
|
46451
|
-
|
|
46452
|
-
|
|
46453
|
-
|
|
46454
|
-
|
|
46455
|
-
|
|
47444
|
+
Ok(Err(error)) => Err(
|
|
47445
|
+
match (
|
|
47446
|
+
"Validator",
|
|
47447
|
+
None,
|
|
47448
|
+
format!("Ruby runtime dispatcher failed for method 'validate': {}", error),
|
|
47449
|
+
) {
|
|
47450
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47451
|
+
message,
|
|
47452
|
+
source: Some(source),
|
|
47453
|
+
},
|
|
47454
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47455
|
+
},
|
|
47456
|
+
),
|
|
47457
|
+
Err(error) => Err(
|
|
47458
|
+
match (
|
|
47459
|
+
"Validator",
|
|
47460
|
+
None,
|
|
47461
|
+
format!("Ruby runtime dispatcher task failed for method 'validate': {}", error),
|
|
47462
|
+
) {
|
|
47463
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47464
|
+
message,
|
|
47465
|
+
source: Some(source),
|
|
47466
|
+
},
|
|
47467
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47468
|
+
},
|
|
47469
|
+
),
|
|
46456
47470
|
}
|
|
46457
47471
|
}
|
|
46458
47472
|
|
|
@@ -46835,10 +47849,19 @@ impl xberg::plugins::Plugin for RbDocumentExtractorBridge {
|
|
|
46835
47849
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
46836
47850
|
Ok(v) => v,
|
|
46837
47851
|
Err(e) => {
|
|
46838
|
-
return Err(
|
|
46839
|
-
|
|
46840
|
-
|
|
46841
|
-
|
|
47852
|
+
return Err(
|
|
47853
|
+
match (
|
|
47854
|
+
"DocumentExtractor",
|
|
47855
|
+
None,
|
|
47856
|
+
format!("Ruby method 'initialize' failed: {}", e),
|
|
47857
|
+
) {
|
|
47858
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47859
|
+
message,
|
|
47860
|
+
source: Some(source),
|
|
47861
|
+
},
|
|
47862
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47863
|
+
},
|
|
47864
|
+
);
|
|
46842
47865
|
}
|
|
46843
47866
|
};
|
|
46844
47867
|
let _ = val;
|
|
@@ -46848,10 +47871,19 @@ impl xberg::plugins::Plugin for RbDocumentExtractorBridge {
|
|
|
46848
47871
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
46849
47872
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
46850
47873
|
Ok(result) => result,
|
|
46851
|
-
Err(error) => Err(
|
|
46852
|
-
|
|
46853
|
-
|
|
46854
|
-
|
|
47874
|
+
Err(error) => Err(
|
|
47875
|
+
match (
|
|
47876
|
+
"DocumentExtractor",
|
|
47877
|
+
None,
|
|
47878
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
47879
|
+
) {
|
|
47880
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47881
|
+
message,
|
|
47882
|
+
source: Some(source),
|
|
47883
|
+
},
|
|
47884
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47885
|
+
},
|
|
47886
|
+
),
|
|
46855
47887
|
},
|
|
46856
47888
|
}
|
|
46857
47889
|
}
|
|
@@ -46864,10 +47896,19 @@ impl xberg::plugins::Plugin for RbDocumentExtractorBridge {
|
|
|
46864
47896
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
46865
47897
|
Ok(v) => v,
|
|
46866
47898
|
Err(e) => {
|
|
46867
|
-
return Err(
|
|
46868
|
-
|
|
46869
|
-
|
|
46870
|
-
|
|
47899
|
+
return Err(
|
|
47900
|
+
match (
|
|
47901
|
+
"DocumentExtractor",
|
|
47902
|
+
None,
|
|
47903
|
+
format!("Ruby method 'shutdown' failed: {}", e),
|
|
47904
|
+
) {
|
|
47905
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47906
|
+
message,
|
|
47907
|
+
source: Some(source),
|
|
47908
|
+
},
|
|
47909
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47910
|
+
},
|
|
47911
|
+
);
|
|
46871
47912
|
}
|
|
46872
47913
|
};
|
|
46873
47914
|
let _ = val;
|
|
@@ -46877,10 +47918,19 @@ impl xberg::plugins::Plugin for RbDocumentExtractorBridge {
|
|
|
46877
47918
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
46878
47919
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
46879
47920
|
Ok(result) => result,
|
|
46880
|
-
Err(error) => Err(
|
|
46881
|
-
|
|
46882
|
-
|
|
46883
|
-
|
|
47921
|
+
Err(error) => Err(
|
|
47922
|
+
match (
|
|
47923
|
+
"DocumentExtractor",
|
|
47924
|
+
None,
|
|
47925
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
47926
|
+
) {
|
|
47927
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47928
|
+
message,
|
|
47929
|
+
source: Some(source),
|
|
47930
|
+
},
|
|
47931
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47932
|
+
},
|
|
47933
|
+
),
|
|
46884
47934
|
},
|
|
46885
47935
|
}
|
|
46886
47936
|
}
|
|
@@ -46914,24 +47964,66 @@ impl xberg::DocumentExtractor for RbDocumentExtractorBridge {
|
|
|
46914
47964
|
) {
|
|
46915
47965
|
Ok(v) => v,
|
|
46916
47966
|
Err(e) => {
|
|
46917
|
-
return Err(
|
|
47967
|
+
return Err(
|
|
47968
|
+
match (
|
|
47969
|
+
"DocumentExtractor",
|
|
47970
|
+
None,
|
|
47971
|
+
format!("Ruby method 'extract' failed: {}", e),
|
|
47972
|
+
) {
|
|
47973
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47974
|
+
message,
|
|
47975
|
+
source: Some(source),
|
|
47976
|
+
},
|
|
47977
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47978
|
+
},
|
|
47979
|
+
);
|
|
46918
47980
|
}
|
|
46919
47981
|
}; // Native-object return: the binding struct's `TryConvert` accepts the host's native wrapped
|
|
46920
47982
|
// object (and still a Hash/JSON via `to_json`); `From<ExtractedDocument>` yields core.
|
|
46921
47983
|
<ExtractedDocument as magnus::TryConvert>::try_convert(val)
|
|
46922
47984
|
.map(Into::into)
|
|
46923
|
-
.map_err(|e|
|
|
47985
|
+
.map_err(|e| {
|
|
47986
|
+
match (
|
|
47987
|
+
"DocumentExtractor",
|
|
47988
|
+
None,
|
|
47989
|
+
format!("Failed to convert Ruby 'extract' return value: {}", e),
|
|
47990
|
+
) {
|
|
47991
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
47992
|
+
message,
|
|
47993
|
+
source: Some(source),
|
|
47994
|
+
},
|
|
47995
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
47996
|
+
}
|
|
47997
|
+
})
|
|
46924
47998
|
};
|
|
46925
47999
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
46926
48000
|
Ok(Ok(result)) => result,
|
|
46927
|
-
Ok(Err(error)) => Err(
|
|
46928
|
-
|
|
46929
|
-
|
|
46930
|
-
|
|
46931
|
-
|
|
46932
|
-
|
|
46933
|
-
|
|
46934
|
-
|
|
48001
|
+
Ok(Err(error)) => Err(
|
|
48002
|
+
match (
|
|
48003
|
+
"DocumentExtractor",
|
|
48004
|
+
None,
|
|
48005
|
+
format!("Ruby runtime dispatcher failed for method 'extract': {}", error),
|
|
48006
|
+
) {
|
|
48007
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48008
|
+
message,
|
|
48009
|
+
source: Some(source),
|
|
48010
|
+
},
|
|
48011
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48012
|
+
},
|
|
48013
|
+
),
|
|
48014
|
+
Err(error) => Err(
|
|
48015
|
+
match (
|
|
48016
|
+
"DocumentExtractor",
|
|
48017
|
+
None,
|
|
48018
|
+
format!("Ruby runtime dispatcher task failed for method 'extract': {}", error),
|
|
48019
|
+
) {
|
|
48020
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48021
|
+
message,
|
|
48022
|
+
source: Some(source),
|
|
48023
|
+
},
|
|
48024
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48025
|
+
},
|
|
48026
|
+
),
|
|
46935
48027
|
}
|
|
46936
48028
|
}
|
|
46937
48029
|
|
|
@@ -47347,10 +48439,19 @@ impl xberg::plugins::Plugin for RbEmbeddingBackendBridge {
|
|
|
47347
48439
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
47348
48440
|
Ok(v) => v,
|
|
47349
48441
|
Err(e) => {
|
|
47350
|
-
return Err(
|
|
47351
|
-
|
|
47352
|
-
|
|
47353
|
-
|
|
48442
|
+
return Err(
|
|
48443
|
+
match (
|
|
48444
|
+
"EmbeddingBackend",
|
|
48445
|
+
None,
|
|
48446
|
+
format!("Ruby method 'initialize' failed: {}", e),
|
|
48447
|
+
) {
|
|
48448
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48449
|
+
message,
|
|
48450
|
+
source: Some(source),
|
|
48451
|
+
},
|
|
48452
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48453
|
+
},
|
|
48454
|
+
);
|
|
47354
48455
|
}
|
|
47355
48456
|
};
|
|
47356
48457
|
let _ = val;
|
|
@@ -47360,10 +48461,19 @@ impl xberg::plugins::Plugin for RbEmbeddingBackendBridge {
|
|
|
47360
48461
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
47361
48462
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
47362
48463
|
Ok(result) => result,
|
|
47363
|
-
Err(error) => Err(
|
|
47364
|
-
|
|
47365
|
-
|
|
47366
|
-
|
|
48464
|
+
Err(error) => Err(
|
|
48465
|
+
match (
|
|
48466
|
+
"EmbeddingBackend",
|
|
48467
|
+
None,
|
|
48468
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
48469
|
+
) {
|
|
48470
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48471
|
+
message,
|
|
48472
|
+
source: Some(source),
|
|
48473
|
+
},
|
|
48474
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48475
|
+
},
|
|
48476
|
+
),
|
|
47367
48477
|
},
|
|
47368
48478
|
}
|
|
47369
48479
|
}
|
|
@@ -47376,10 +48486,19 @@ impl xberg::plugins::Plugin for RbEmbeddingBackendBridge {
|
|
|
47376
48486
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
47377
48487
|
Ok(v) => v,
|
|
47378
48488
|
Err(e) => {
|
|
47379
|
-
return Err(
|
|
47380
|
-
|
|
47381
|
-
|
|
47382
|
-
|
|
48489
|
+
return Err(
|
|
48490
|
+
match (
|
|
48491
|
+
"EmbeddingBackend",
|
|
48492
|
+
None,
|
|
48493
|
+
format!("Ruby method 'shutdown' failed: {}", e),
|
|
48494
|
+
) {
|
|
48495
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48496
|
+
message,
|
|
48497
|
+
source: Some(source),
|
|
48498
|
+
},
|
|
48499
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48500
|
+
},
|
|
48501
|
+
);
|
|
47383
48502
|
}
|
|
47384
48503
|
};
|
|
47385
48504
|
let _ = val;
|
|
@@ -47389,10 +48508,19 @@ impl xberg::plugins::Plugin for RbEmbeddingBackendBridge {
|
|
|
47389
48508
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
47390
48509
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
47391
48510
|
Ok(result) => result,
|
|
47392
|
-
Err(error) => Err(
|
|
47393
|
-
|
|
47394
|
-
|
|
47395
|
-
|
|
48511
|
+
Err(error) => Err(
|
|
48512
|
+
match (
|
|
48513
|
+
"EmbeddingBackend",
|
|
48514
|
+
None,
|
|
48515
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
48516
|
+
) {
|
|
48517
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48518
|
+
message,
|
|
48519
|
+
source: Some(source),
|
|
48520
|
+
},
|
|
48521
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48522
|
+
},
|
|
48523
|
+
),
|
|
47396
48524
|
},
|
|
47397
48525
|
}
|
|
47398
48526
|
}
|
|
@@ -47432,34 +48560,70 @@ impl xberg::EmbeddingBackend for RbEmbeddingBackendBridge {
|
|
|
47432
48560
|
async fn embed(&self, texts: Vec<String>) -> std::result::Result<Vec<Vec<f32>>, xberg::XbergError> {
|
|
47433
48561
|
let texts_owned = texts;
|
|
47434
48562
|
let dispatcher = self.runtime_dispatcher.clone();
|
|
47435
|
-
let callback =
|
|
47436
|
-
|
|
47437
|
-
|
|
47438
|
-
|
|
47439
|
-
|
|
47440
|
-
|
|
47441
|
-
|
|
47442
|
-
|
|
47443
|
-
|
|
47444
|
-
|
|
47445
|
-
|
|
47446
|
-
|
|
47447
|
-
|
|
47448
|
-
|
|
48563
|
+
let callback =
|
|
48564
|
+
move |ruby: &magnus::Ruby, value: magnus::Value| -> std::result::Result<Vec<Vec<f32>>, xberg::XbergError> {
|
|
48565
|
+
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>(
|
|
48566
|
+
"embed",
|
|
48567
|
+
(serde_json::to_string(&texts_owned)
|
|
48568
|
+
.ok()
|
|
48569
|
+
.map(|s| ruby.str_new(s.as_str()).as_value())
|
|
48570
|
+
.unwrap_or_else(|| ruby.qnil().as_value()),),
|
|
48571
|
+
) {
|
|
48572
|
+
Ok(v) => v,
|
|
48573
|
+
Err(e) => {
|
|
48574
|
+
return Err(
|
|
48575
|
+
match ("EmbeddingBackend", None, format!("Ruby method 'embed' failed: {}", e)) {
|
|
48576
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48577
|
+
message,
|
|
48578
|
+
source: Some(source),
|
|
48579
|
+
},
|
|
48580
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48581
|
+
},
|
|
48582
|
+
);
|
|
48583
|
+
}
|
|
48584
|
+
};
|
|
48585
|
+
<Vec<Vec<f32>> as magnus::TryConvert>::try_convert(val).map_err(|e| {
|
|
48586
|
+
match (
|
|
48587
|
+
"EmbeddingBackend",
|
|
48588
|
+
None,
|
|
48589
|
+
format!("Failed to convert Ruby 'embed' return value: {}", e),
|
|
48590
|
+
) {
|
|
48591
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48592
|
+
message,
|
|
48593
|
+
source: Some(source),
|
|
48594
|
+
},
|
|
48595
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48596
|
+
}
|
|
48597
|
+
})
|
|
47449
48598
|
};
|
|
47450
|
-
<Vec<Vec<f32>> as magnus::TryConvert>::try_convert(val)
|
|
47451
|
-
.map_err(|e| xberg::XbergError::Other(format!("Failed to convert Ruby 'embed' return value: {}", e)))
|
|
47452
|
-
};
|
|
47453
48599
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
47454
48600
|
Ok(Ok(result)) => result,
|
|
47455
|
-
Ok(Err(error)) => Err(
|
|
47456
|
-
|
|
47457
|
-
|
|
47458
|
-
|
|
47459
|
-
|
|
47460
|
-
|
|
47461
|
-
|
|
47462
|
-
|
|
48601
|
+
Ok(Err(error)) => Err(
|
|
48602
|
+
match (
|
|
48603
|
+
"EmbeddingBackend",
|
|
48604
|
+
None,
|
|
48605
|
+
format!("Ruby runtime dispatcher failed for method 'embed': {}", error),
|
|
48606
|
+
) {
|
|
48607
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48608
|
+
message,
|
|
48609
|
+
source: Some(source),
|
|
48610
|
+
},
|
|
48611
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48612
|
+
},
|
|
48613
|
+
),
|
|
48614
|
+
Err(error) => Err(
|
|
48615
|
+
match (
|
|
48616
|
+
"EmbeddingBackend",
|
|
48617
|
+
None,
|
|
48618
|
+
format!("Ruby runtime dispatcher task failed for method 'embed': {}", error),
|
|
48619
|
+
) {
|
|
48620
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48621
|
+
message,
|
|
48622
|
+
source: Some(source),
|
|
48623
|
+
},
|
|
48624
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48625
|
+
},
|
|
48626
|
+
),
|
|
47463
48627
|
}
|
|
47464
48628
|
}
|
|
47465
48629
|
}
|
|
@@ -47676,10 +48840,15 @@ impl xberg::plugins::Plugin for RbRendererBridge {
|
|
|
47676
48840
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
47677
48841
|
Ok(v) => v,
|
|
47678
48842
|
Err(e) => {
|
|
47679
|
-
return Err(
|
|
47680
|
-
"Ruby method 'initialize' failed: {}",
|
|
47681
|
-
|
|
47682
|
-
|
|
48843
|
+
return Err(
|
|
48844
|
+
match ("Renderer", None, format!("Ruby method 'initialize' failed: {}", e)) {
|
|
48845
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48846
|
+
message,
|
|
48847
|
+
source: Some(source),
|
|
48848
|
+
},
|
|
48849
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48850
|
+
},
|
|
48851
|
+
);
|
|
47683
48852
|
}
|
|
47684
48853
|
};
|
|
47685
48854
|
let _ = val;
|
|
@@ -47689,10 +48858,19 @@ impl xberg::plugins::Plugin for RbRendererBridge {
|
|
|
47689
48858
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
47690
48859
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
47691
48860
|
Ok(result) => result,
|
|
47692
|
-
Err(error) => Err(
|
|
47693
|
-
|
|
47694
|
-
|
|
47695
|
-
|
|
48861
|
+
Err(error) => Err(
|
|
48862
|
+
match (
|
|
48863
|
+
"Renderer",
|
|
48864
|
+
None,
|
|
48865
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
48866
|
+
) {
|
|
48867
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48868
|
+
message,
|
|
48869
|
+
source: Some(source),
|
|
48870
|
+
},
|
|
48871
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48872
|
+
},
|
|
48873
|
+
),
|
|
47696
48874
|
},
|
|
47697
48875
|
}
|
|
47698
48876
|
}
|
|
@@ -47705,10 +48883,15 @@ impl xberg::plugins::Plugin for RbRendererBridge {
|
|
|
47705
48883
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
47706
48884
|
Ok(v) => v,
|
|
47707
48885
|
Err(e) => {
|
|
47708
|
-
return Err(
|
|
47709
|
-
"Ruby method 'shutdown' failed: {}",
|
|
47710
|
-
|
|
47711
|
-
|
|
48886
|
+
return Err(
|
|
48887
|
+
match ("Renderer", None, format!("Ruby method 'shutdown' failed: {}", e)) {
|
|
48888
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48889
|
+
message,
|
|
48890
|
+
source: Some(source),
|
|
48891
|
+
},
|
|
48892
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48893
|
+
},
|
|
48894
|
+
);
|
|
47712
48895
|
}
|
|
47713
48896
|
};
|
|
47714
48897
|
let _ = val;
|
|
@@ -47718,10 +48901,19 @@ impl xberg::plugins::Plugin for RbRendererBridge {
|
|
|
47718
48901
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
47719
48902
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
47720
48903
|
Ok(result) => result,
|
|
47721
|
-
Err(error) => Err(
|
|
47722
|
-
|
|
47723
|
-
|
|
47724
|
-
|
|
48904
|
+
Err(error) => Err(
|
|
48905
|
+
match (
|
|
48906
|
+
"Renderer",
|
|
48907
|
+
None,
|
|
48908
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
48909
|
+
) {
|
|
48910
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48911
|
+
message,
|
|
48912
|
+
source: Some(source),
|
|
48913
|
+
},
|
|
48914
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48915
|
+
},
|
|
48916
|
+
),
|
|
47725
48917
|
},
|
|
47726
48918
|
}
|
|
47727
48919
|
}
|
|
@@ -47744,24 +48936,48 @@ impl xberg::Renderer for RbRendererBridge {
|
|
|
47744
48936
|
) {
|
|
47745
48937
|
Ok(v) => v,
|
|
47746
48938
|
Err(e) => {
|
|
47747
|
-
return Err(
|
|
47748
|
-
"Ruby method 'render_result' failed: {}",
|
|
47749
|
-
|
|
47750
|
-
|
|
48939
|
+
return Err(
|
|
48940
|
+
match ("Renderer", None, format!("Ruby method 'render_result' failed: {}", e)) {
|
|
48941
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48942
|
+
message,
|
|
48943
|
+
source: Some(source),
|
|
48944
|
+
},
|
|
48945
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48946
|
+
},
|
|
48947
|
+
);
|
|
47751
48948
|
}
|
|
47752
48949
|
};
|
|
47753
48950
|
<String as magnus::TryConvert>::try_convert(val).map_err(|e| {
|
|
47754
|
-
|
|
48951
|
+
match (
|
|
48952
|
+
"Renderer",
|
|
48953
|
+
None,
|
|
48954
|
+
format!("Failed to convert Ruby 'render_result' return value: {}", e),
|
|
48955
|
+
) {
|
|
48956
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48957
|
+
message,
|
|
48958
|
+
source: Some(source),
|
|
48959
|
+
},
|
|
48960
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48961
|
+
}
|
|
47755
48962
|
})
|
|
47756
48963
|
};
|
|
47757
48964
|
match magnus::Ruby::get() {
|
|
47758
48965
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
47759
48966
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
47760
48967
|
Ok(result) => result,
|
|
47761
|
-
Err(error) => Err(
|
|
47762
|
-
|
|
47763
|
-
|
|
47764
|
-
|
|
48968
|
+
Err(error) => Err(
|
|
48969
|
+
match (
|
|
48970
|
+
"Renderer",
|
|
48971
|
+
None,
|
|
48972
|
+
format!("Ruby runtime dispatcher failed for method 'render_result': {}", error),
|
|
48973
|
+
) {
|
|
48974
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
48975
|
+
message,
|
|
48976
|
+
source: Some(source),
|
|
48977
|
+
},
|
|
48978
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
48979
|
+
},
|
|
48980
|
+
),
|
|
47765
48981
|
},
|
|
47766
48982
|
}
|
|
47767
48983
|
}
|
|
@@ -47998,10 +49214,19 @@ impl xberg::plugins::Plugin for RbRerankerBackendBridge {
|
|
|
47998
49214
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
47999
49215
|
Ok(v) => v,
|
|
48000
49216
|
Err(e) => {
|
|
48001
|
-
return Err(
|
|
48002
|
-
|
|
48003
|
-
|
|
48004
|
-
|
|
49217
|
+
return Err(
|
|
49218
|
+
match (
|
|
49219
|
+
"RerankerBackend",
|
|
49220
|
+
None,
|
|
49221
|
+
format!("Ruby method 'initialize' failed: {}", e),
|
|
49222
|
+
) {
|
|
49223
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49224
|
+
message,
|
|
49225
|
+
source: Some(source),
|
|
49226
|
+
},
|
|
49227
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49228
|
+
},
|
|
49229
|
+
);
|
|
48005
49230
|
}
|
|
48006
49231
|
};
|
|
48007
49232
|
let _ = val;
|
|
@@ -48011,10 +49236,19 @@ impl xberg::plugins::Plugin for RbRerankerBackendBridge {
|
|
|
48011
49236
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
48012
49237
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
48013
49238
|
Ok(result) => result,
|
|
48014
|
-
Err(error) => Err(
|
|
48015
|
-
|
|
48016
|
-
|
|
48017
|
-
|
|
49239
|
+
Err(error) => Err(
|
|
49240
|
+
match (
|
|
49241
|
+
"RerankerBackend",
|
|
49242
|
+
None,
|
|
49243
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
49244
|
+
) {
|
|
49245
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49246
|
+
message,
|
|
49247
|
+
source: Some(source),
|
|
49248
|
+
},
|
|
49249
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49250
|
+
},
|
|
49251
|
+
),
|
|
48018
49252
|
},
|
|
48019
49253
|
}
|
|
48020
49254
|
}
|
|
@@ -48027,10 +49261,15 @@ impl xberg::plugins::Plugin for RbRerankerBackendBridge {
|
|
|
48027
49261
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
48028
49262
|
Ok(v) => v,
|
|
48029
49263
|
Err(e) => {
|
|
48030
|
-
return Err(
|
|
48031
|
-
"Ruby method 'shutdown' failed: {}",
|
|
48032
|
-
|
|
48033
|
-
|
|
49264
|
+
return Err(
|
|
49265
|
+
match ("RerankerBackend", None, format!("Ruby method 'shutdown' failed: {}", e)) {
|
|
49266
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49267
|
+
message,
|
|
49268
|
+
source: Some(source),
|
|
49269
|
+
},
|
|
49270
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49271
|
+
},
|
|
49272
|
+
);
|
|
48034
49273
|
}
|
|
48035
49274
|
};
|
|
48036
49275
|
let _ = val;
|
|
@@ -48040,10 +49279,19 @@ impl xberg::plugins::Plugin for RbRerankerBackendBridge {
|
|
|
48040
49279
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
48041
49280
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
48042
49281
|
Ok(result) => result,
|
|
48043
|
-
Err(error) => Err(
|
|
48044
|
-
|
|
48045
|
-
|
|
48046
|
-
|
|
49282
|
+
Err(error) => Err(
|
|
49283
|
+
match (
|
|
49284
|
+
"RerankerBackend",
|
|
49285
|
+
None,
|
|
49286
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
49287
|
+
) {
|
|
49288
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49289
|
+
message,
|
|
49290
|
+
source: Some(source),
|
|
49291
|
+
},
|
|
49292
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49293
|
+
},
|
|
49294
|
+
),
|
|
48047
49295
|
},
|
|
48048
49296
|
}
|
|
48049
49297
|
}
|
|
@@ -48055,37 +49303,73 @@ impl xberg::RerankerBackend for RbRerankerBackendBridge {
|
|
|
48055
49303
|
let query_owned = query;
|
|
48056
49304
|
let documents_owned = documents;
|
|
48057
49305
|
let dispatcher = self.runtime_dispatcher.clone();
|
|
48058
|
-
let callback =
|
|
48059
|
-
|
|
48060
|
-
|
|
48061
|
-
|
|
48062
|
-
|
|
48063
|
-
|
|
48064
|
-
|
|
48065
|
-
|
|
48066
|
-
|
|
48067
|
-
|
|
48068
|
-
|
|
48069
|
-
)
|
|
48070
|
-
|
|
48071
|
-
|
|
48072
|
-
|
|
48073
|
-
|
|
48074
|
-
|
|
49306
|
+
let callback =
|
|
49307
|
+
move |ruby: &magnus::Ruby, value: magnus::Value| -> std::result::Result<Vec<f32>, xberg::XbergError> {
|
|
49308
|
+
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>(
|
|
49309
|
+
"rerank",
|
|
49310
|
+
(
|
|
49311
|
+
ruby.str_new(AsRef::<str>::as_ref(&query_owned)).as_value(),
|
|
49312
|
+
serde_json::to_string(&documents_owned)
|
|
49313
|
+
.ok()
|
|
49314
|
+
.map(|s| ruby.str_new(s.as_str()).as_value())
|
|
49315
|
+
.unwrap_or_else(|| ruby.qnil().as_value()),
|
|
49316
|
+
),
|
|
49317
|
+
) {
|
|
49318
|
+
Ok(v) => v,
|
|
49319
|
+
Err(e) => {
|
|
49320
|
+
return Err(
|
|
49321
|
+
match ("RerankerBackend", None, format!("Ruby method 'rerank' failed: {}", e)) {
|
|
49322
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49323
|
+
message,
|
|
49324
|
+
source: Some(source),
|
|
49325
|
+
},
|
|
49326
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49327
|
+
},
|
|
49328
|
+
);
|
|
49329
|
+
}
|
|
49330
|
+
};
|
|
49331
|
+
<Vec<f32> as magnus::TryConvert>::try_convert(val).map_err(|e| {
|
|
49332
|
+
match (
|
|
49333
|
+
"RerankerBackend",
|
|
49334
|
+
None,
|
|
49335
|
+
format!("Failed to convert Ruby 'rerank' return value: {}", e),
|
|
49336
|
+
) {
|
|
49337
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49338
|
+
message,
|
|
49339
|
+
source: Some(source),
|
|
49340
|
+
},
|
|
49341
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49342
|
+
}
|
|
49343
|
+
})
|
|
48075
49344
|
};
|
|
48076
|
-
<Vec<f32> as magnus::TryConvert>::try_convert(val)
|
|
48077
|
-
.map_err(|e| xberg::XbergError::Other(format!("Failed to convert Ruby 'rerank' return value: {}", e)))
|
|
48078
|
-
};
|
|
48079
49345
|
match tokio::task::spawn_blocking(move || dispatcher.dispatch(callback)).await {
|
|
48080
49346
|
Ok(Ok(result)) => result,
|
|
48081
|
-
Ok(Err(error)) => Err(
|
|
48082
|
-
|
|
48083
|
-
|
|
48084
|
-
|
|
48085
|
-
|
|
48086
|
-
|
|
48087
|
-
|
|
48088
|
-
|
|
49347
|
+
Ok(Err(error)) => Err(
|
|
49348
|
+
match (
|
|
49349
|
+
"RerankerBackend",
|
|
49350
|
+
None,
|
|
49351
|
+
format!("Ruby runtime dispatcher failed for method 'rerank': {}", error),
|
|
49352
|
+
) {
|
|
49353
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49354
|
+
message,
|
|
49355
|
+
source: Some(source),
|
|
49356
|
+
},
|
|
49357
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49358
|
+
},
|
|
49359
|
+
),
|
|
49360
|
+
Err(error) => Err(
|
|
49361
|
+
match (
|
|
49362
|
+
"RerankerBackend",
|
|
49363
|
+
None,
|
|
49364
|
+
format!("Ruby runtime dispatcher task failed for method 'rerank': {}", error),
|
|
49365
|
+
) {
|
|
49366
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49367
|
+
message,
|
|
49368
|
+
source: Some(source),
|
|
49369
|
+
},
|
|
49370
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49371
|
+
},
|
|
49372
|
+
),
|
|
48089
49373
|
}
|
|
48090
49374
|
}
|
|
48091
49375
|
}
|
|
@@ -48307,10 +49591,19 @@ impl xberg::plugins::Plugin for RbTokenizerBackendBridge {
|
|
|
48307
49591
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("initialize", ()) {
|
|
48308
49592
|
Ok(v) => v,
|
|
48309
49593
|
Err(e) => {
|
|
48310
|
-
return Err(
|
|
48311
|
-
|
|
48312
|
-
|
|
48313
|
-
|
|
49594
|
+
return Err(
|
|
49595
|
+
match (
|
|
49596
|
+
"TokenizerBackend",
|
|
49597
|
+
None,
|
|
49598
|
+
format!("Ruby method 'initialize' failed: {}", e),
|
|
49599
|
+
) {
|
|
49600
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49601
|
+
message,
|
|
49602
|
+
source: Some(source),
|
|
49603
|
+
},
|
|
49604
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49605
|
+
},
|
|
49606
|
+
);
|
|
48314
49607
|
}
|
|
48315
49608
|
};
|
|
48316
49609
|
let _ = val;
|
|
@@ -48320,10 +49613,19 @@ impl xberg::plugins::Plugin for RbTokenizerBackendBridge {
|
|
|
48320
49613
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
48321
49614
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
48322
49615
|
Ok(result) => result,
|
|
48323
|
-
Err(error) => Err(
|
|
48324
|
-
|
|
48325
|
-
|
|
48326
|
-
|
|
49616
|
+
Err(error) => Err(
|
|
49617
|
+
match (
|
|
49618
|
+
"TokenizerBackend",
|
|
49619
|
+
None,
|
|
49620
|
+
format!("Ruby runtime dispatcher failed for method 'initialize': {}", error),
|
|
49621
|
+
) {
|
|
49622
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49623
|
+
message,
|
|
49624
|
+
source: Some(source),
|
|
49625
|
+
},
|
|
49626
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49627
|
+
},
|
|
49628
|
+
),
|
|
48327
49629
|
},
|
|
48328
49630
|
}
|
|
48329
49631
|
}
|
|
@@ -48336,10 +49638,19 @@ impl xberg::plugins::Plugin for RbTokenizerBackendBridge {
|
|
|
48336
49638
|
let val: magnus::Value = match value.funcall::<_, _, magnus::Value>("shutdown", ()) {
|
|
48337
49639
|
Ok(v) => v,
|
|
48338
49640
|
Err(e) => {
|
|
48339
|
-
return Err(
|
|
48340
|
-
|
|
48341
|
-
|
|
48342
|
-
|
|
49641
|
+
return Err(
|
|
49642
|
+
match (
|
|
49643
|
+
"TokenizerBackend",
|
|
49644
|
+
None,
|
|
49645
|
+
format!("Ruby method 'shutdown' failed: {}", e),
|
|
49646
|
+
) {
|
|
49647
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49648
|
+
message,
|
|
49649
|
+
source: Some(source),
|
|
49650
|
+
},
|
|
49651
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49652
|
+
},
|
|
49653
|
+
);
|
|
48343
49654
|
}
|
|
48344
49655
|
};
|
|
48345
49656
|
let _ = val;
|
|
@@ -48349,10 +49660,19 @@ impl xberg::plugins::Plugin for RbTokenizerBackendBridge {
|
|
|
48349
49660
|
Ok(ruby) => callback(&ruby, self.inner.get_inner_with(&ruby)),
|
|
48350
49661
|
Err(_) => match self.runtime_dispatcher.dispatch(callback) {
|
|
48351
49662
|
Ok(result) => result,
|
|
48352
|
-
Err(error) => Err(
|
|
48353
|
-
|
|
48354
|
-
|
|
48355
|
-
|
|
49663
|
+
Err(error) => Err(
|
|
49664
|
+
match (
|
|
49665
|
+
"TokenizerBackend",
|
|
49666
|
+
None,
|
|
49667
|
+
format!("Ruby runtime dispatcher failed for method 'shutdown': {}", error),
|
|
49668
|
+
) {
|
|
49669
|
+
("OcrBackend", Some(source), message) => xberg::XbergError::Ocr {
|
|
49670
|
+
message,
|
|
49671
|
+
source: Some(source),
|
|
49672
|
+
},
|
|
49673
|
+
(_, _, message) => xberg::XbergError::Other(message),
|
|
49674
|
+
},
|
|
49675
|
+
),
|
|
48356
49676
|
},
|
|
48357
49677
|
}
|
|
48358
49678
|
}
|
|
@@ -48669,6 +49989,9 @@ impl From<BrowserConfig> for crawlberg::BrowserConfig {
|
|
|
48669
49989
|
session_affinity: val.session_affinity,
|
|
48670
49990
|
chrome_path: val.chrome_path.map(Into::into),
|
|
48671
49991
|
chrome_args: val.chrome_args.into_iter().collect(),
|
|
49992
|
+
scroll_containers: val.scroll_containers,
|
|
49993
|
+
dom_quiet_window: std::time::Duration::from_millis(val.dom_quiet_window),
|
|
49994
|
+
dom_quiet_cap: std::time::Duration::from_millis(val.dom_quiet_cap),
|
|
48672
49995
|
..Default::default()
|
|
48673
49996
|
}
|
|
48674
49997
|
}
|
|
@@ -48695,6 +50018,9 @@ impl From<crawlberg::BrowserConfig> for BrowserConfig {
|
|
|
48695
50018
|
session_affinity: val.session_affinity,
|
|
48696
50019
|
chrome_path: val.chrome_path.map(|p| p.to_string_lossy().to_string()),
|
|
48697
50020
|
chrome_args: val.chrome_args.into_iter().collect(),
|
|
50021
|
+
scroll_containers: val.scroll_containers,
|
|
50022
|
+
dom_quiet_window: val.dom_quiet_window.as_millis() as u64,
|
|
50023
|
+
dom_quiet_cap: val.dom_quiet_cap.as_millis() as u64,
|
|
48698
50024
|
}
|
|
48699
50025
|
}
|
|
48700
50026
|
}
|
|
@@ -49150,6 +50476,17 @@ impl From<ContentConfig> for crawlberg::ContentConfig {
|
|
|
49150
50476
|
wrap_width: val.wrap_width,
|
|
49151
50477
|
include_document_structure: val.include_document_structure,
|
|
49152
50478
|
extract_metadata: val.extract_metadata,
|
|
50479
|
+
strip_newlines: val.strip_newlines,
|
|
50480
|
+
bullets: val.bullets,
|
|
50481
|
+
list_indent_width: val.list_indent_width,
|
|
50482
|
+
strong_em_symbol: val.strong_em_symbol,
|
|
50483
|
+
compact_tables: val.compact_tables,
|
|
50484
|
+
keep_inline_images_in: val.keep_inline_images_in.into_iter().collect(),
|
|
50485
|
+
keep_hidden: val.keep_hidden,
|
|
50486
|
+
expand_abbreviations: val.expand_abbreviations,
|
|
50487
|
+
escape_misc: val.escape_misc,
|
|
50488
|
+
escape_asterisks: val.escape_asterisks,
|
|
50489
|
+
include_icon_labels: val.include_icon_labels,
|
|
49153
50490
|
..Default::default()
|
|
49154
50491
|
}
|
|
49155
50492
|
}
|
|
@@ -49171,6 +50508,17 @@ impl From<crawlberg::ContentConfig> for ContentConfig {
|
|
|
49171
50508
|
wrap_width: val.wrap_width,
|
|
49172
50509
|
include_document_structure: val.include_document_structure,
|
|
49173
50510
|
extract_metadata: val.extract_metadata,
|
|
50511
|
+
strip_newlines: val.strip_newlines,
|
|
50512
|
+
bullets: val.bullets.to_string(),
|
|
50513
|
+
list_indent_width: val.list_indent_width,
|
|
50514
|
+
strong_em_symbol: val.strong_em_symbol.to_string(),
|
|
50515
|
+
compact_tables: val.compact_tables,
|
|
50516
|
+
keep_inline_images_in: val.keep_inline_images_in.into_iter().collect(),
|
|
50517
|
+
keep_hidden: val.keep_hidden,
|
|
50518
|
+
expand_abbreviations: val.expand_abbreviations,
|
|
50519
|
+
escape_misc: val.escape_misc,
|
|
50520
|
+
escape_asterisks: val.escape_asterisks,
|
|
50521
|
+
include_icon_labels: val.include_icon_labels,
|
|
49174
50522
|
}
|
|
49175
50523
|
}
|
|
49176
50524
|
}
|
|
@@ -49236,6 +50584,8 @@ impl From<ConversionOptions> for html_to_markdown_rs::ConversionOptions {
|
|
|
49236
50584
|
escape_ascii: val.escape_ascii,
|
|
49237
50585
|
code_language: val.code_language,
|
|
49238
50586
|
autolinks: val.autolinks,
|
|
50587
|
+
expand_abbreviations: val.expand_abbreviations,
|
|
50588
|
+
include_blockquote_citations: val.include_blockquote_citations,
|
|
49239
50589
|
default_title: val.default_title,
|
|
49240
50590
|
br_in_tables: val.br_in_tables,
|
|
49241
50591
|
compact_tables: val.compact_tables,
|
|
@@ -49258,6 +50608,7 @@ impl From<ConversionOptions> for html_to_markdown_rs::ConversionOptions {
|
|
|
49258
50608
|
preserve_tags: val.preserve_tags.into_iter().collect(),
|
|
49259
50609
|
skip_images: val.skip_images,
|
|
49260
50610
|
inline_data_media: val.inline_data_media.into(),
|
|
50611
|
+
hidden_content: val.hidden_content.into(),
|
|
49261
50612
|
url_escape_style: val.url_escape_style.into(),
|
|
49262
50613
|
link_style: val.link_style.into(),
|
|
49263
50614
|
output_format: val.output_format.into(),
|
|
@@ -49291,6 +50642,8 @@ impl From<html_to_markdown_rs::ConversionOptions> for ConversionOptions {
|
|
|
49291
50642
|
escape_ascii: val.escape_ascii,
|
|
49292
50643
|
code_language: val.code_language.to_string(),
|
|
49293
50644
|
autolinks: val.autolinks,
|
|
50645
|
+
expand_abbreviations: val.expand_abbreviations,
|
|
50646
|
+
include_blockquote_citations: val.include_blockquote_citations,
|
|
49294
50647
|
default_title: val.default_title,
|
|
49295
50648
|
br_in_tables: val.br_in_tables,
|
|
49296
50649
|
compact_tables: val.compact_tables,
|
|
@@ -49313,6 +50666,7 @@ impl From<html_to_markdown_rs::ConversionOptions> for ConversionOptions {
|
|
|
49313
50666
|
preserve_tags: val.preserve_tags.into_iter().collect(),
|
|
49314
50667
|
skip_images: val.skip_images,
|
|
49315
50668
|
inline_data_media: val.inline_data_media.into(),
|
|
50669
|
+
hidden_content: val.hidden_content.into(),
|
|
49316
50670
|
url_escape_style: val.url_escape_style.into(),
|
|
49317
50671
|
link_style: val.link_style.into(),
|
|
49318
50672
|
output_format: val.output_format.into(),
|
|
@@ -49443,6 +50797,8 @@ impl From<CrawlConfig> for crawlberg::CrawlConfig {
|
|
|
49443
50797
|
save_browser_profile: val.save_browser_profile,
|
|
49444
50798
|
ssrf: val.ssrf.into(),
|
|
49445
50799
|
ssrf_deny_private_explicit: val.ssrf_deny_private_explicit,
|
|
50800
|
+
danger_accept_invalid_certs: val.danger_accept_invalid_certs,
|
|
50801
|
+
subdomain_header_allowlist: val.subdomain_header_allowlist.into_iter().collect(),
|
|
49446
50802
|
..Default::default()
|
|
49447
50803
|
}
|
|
49448
50804
|
}
|
|
@@ -49511,6 +50867,8 @@ impl From<crawlberg::CrawlConfig> for CrawlConfig {
|
|
|
49511
50867
|
save_browser_profile: val.save_browser_profile,
|
|
49512
50868
|
ssrf: val.ssrf.into(),
|
|
49513
50869
|
ssrf_deny_private_explicit: val.ssrf_deny_private_explicit,
|
|
50870
|
+
danger_accept_invalid_certs: val.danger_accept_invalid_certs,
|
|
50871
|
+
subdomain_header_allowlist: val.subdomain_header_allowlist.into_iter().collect(),
|
|
49514
50872
|
}
|
|
49515
50873
|
}
|
|
49516
50874
|
}
|
|
@@ -50495,6 +51853,27 @@ impl From<xberg::ExtractInput> for ExtractInput {
|
|
|
50495
51853
|
}
|
|
50496
51854
|
}
|
|
50497
51855
|
|
|
51856
|
+
#[allow(clippy::field_reassign_with_default, clippy::let_and_return)]
|
|
51857
|
+
#[allow(clippy::useless_conversion)]
|
|
51858
|
+
impl From<ExtractInputWithOptions> for xberg::ExtractInputWithOptions {
|
|
51859
|
+
fn from(val: ExtractInputWithOptions) -> Self {
|
|
51860
|
+
let mut __result = xberg::ExtractInputWithOptions::default();
|
|
51861
|
+
__result.input = val.input.into();
|
|
51862
|
+
__result.use_layout_for_markdown = val.use_layout_for_markdown;
|
|
51863
|
+
__result
|
|
51864
|
+
}
|
|
51865
|
+
}
|
|
51866
|
+
|
|
51867
|
+
#[allow(clippy::useless_conversion)]
|
|
51868
|
+
impl From<xberg::ExtractInputWithOptions> for ExtractInputWithOptions {
|
|
51869
|
+
fn from(val: xberg::ExtractInputWithOptions) -> Self {
|
|
51870
|
+
Self {
|
|
51871
|
+
input: val.input.into(),
|
|
51872
|
+
use_layout_for_markdown: val.use_layout_for_markdown,
|
|
51873
|
+
}
|
|
51874
|
+
}
|
|
51875
|
+
}
|
|
51876
|
+
|
|
50498
51877
|
#[allow(clippy::field_reassign_with_default, clippy::let_and_return)]
|
|
50499
51878
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
50500
51879
|
impl From<ExtractedDocument> for xberg::ExtractedDocument {
|
|
@@ -52021,6 +53400,7 @@ impl From<LayoutDetectionConfig> for xberg::LayoutDetectionConfig {
|
|
|
52021
53400
|
table_overlap_preference: val.table_overlap_preference.into(),
|
|
52022
53401
|
acceleration: val.acceleration.map(Into::into),
|
|
52023
53402
|
enable_chart_understanding: val.enable_chart_understanding,
|
|
53403
|
+
model: val.model.into(),
|
|
52024
53404
|
..Default::default()
|
|
52025
53405
|
}
|
|
52026
53406
|
}
|
|
@@ -52039,6 +53419,7 @@ impl From<xberg::LayoutDetectionConfig> for LayoutDetectionConfig {
|
|
|
52039
53419
|
table_overlap_preference: val.table_overlap_preference.into(),
|
|
52040
53420
|
acceleration: val.acceleration.map(Into::into),
|
|
52041
53421
|
enable_chart_understanding: val.enable_chart_understanding,
|
|
53422
|
+
model: val.model.into(),
|
|
52042
53423
|
}
|
|
52043
53424
|
}
|
|
52044
53425
|
}
|
|
@@ -52881,6 +54262,7 @@ impl From<OcrQualityThresholds> for xberg::OcrQualityThresholds {
|
|
|
52881
54262
|
min_words_for_ocr_output_check: val.min_words_for_ocr_output_check,
|
|
52882
54263
|
max_ocr_output_dict_invalid_word_ratio: val.max_ocr_output_dict_invalid_word_ratio,
|
|
52883
54264
|
discard_suspected_ocr_noise: val.discard_suspected_ocr_noise,
|
|
54265
|
+
prune_symbol_noise_lines: val.prune_symbol_noise_lines,
|
|
52884
54266
|
min_avg_word_length: val.min_avg_word_length,
|
|
52885
54267
|
min_words_for_avg_length_check: val.min_words_for_avg_length_check,
|
|
52886
54268
|
min_consecutive_repeat_ratio: val.min_consecutive_repeat_ratio,
|
|
@@ -52915,6 +54297,7 @@ impl From<xberg::OcrQualityThresholds> for OcrQualityThresholds {
|
|
|
52915
54297
|
min_words_for_ocr_output_check: val.min_words_for_ocr_output_check,
|
|
52916
54298
|
max_ocr_output_dict_invalid_word_ratio: val.max_ocr_output_dict_invalid_word_ratio,
|
|
52917
54299
|
discard_suspected_ocr_noise: val.discard_suspected_ocr_noise,
|
|
54300
|
+
prune_symbol_noise_lines: val.prune_symbol_noise_lines,
|
|
52918
54301
|
min_avg_word_length: val.min_avg_word_length,
|
|
52919
54302
|
min_words_for_avg_length_check: val.min_words_for_avg_length_check,
|
|
52920
54303
|
min_consecutive_repeat_ratio: val.min_consecutive_repeat_ratio,
|
|
@@ -56091,6 +57474,26 @@ impl From<html_to_markdown_rs::HeadingStyle> for HeadingStyle {
|
|
|
56091
57474
|
}
|
|
56092
57475
|
}
|
|
56093
57476
|
|
|
57477
|
+
impl From<HiddenContent> for html_to_markdown_rs::HiddenContent {
|
|
57478
|
+
fn from(val: HiddenContent) -> Self {
|
|
57479
|
+
match val {
|
|
57480
|
+
HiddenContent::Drop => Self::Drop,
|
|
57481
|
+
HiddenContent::Reachable => Self::Reachable,
|
|
57482
|
+
HiddenContent::All => Self::All,
|
|
57483
|
+
}
|
|
57484
|
+
}
|
|
57485
|
+
}
|
|
57486
|
+
|
|
57487
|
+
impl From<html_to_markdown_rs::HiddenContent> for HiddenContent {
|
|
57488
|
+
fn from(val: html_to_markdown_rs::HiddenContent) -> Self {
|
|
57489
|
+
match val {
|
|
57490
|
+
html_to_markdown_rs::HiddenContent::Drop => Self::Drop,
|
|
57491
|
+
html_to_markdown_rs::HiddenContent::Reachable => Self::Reachable,
|
|
57492
|
+
html_to_markdown_rs::HiddenContent::All => Self::All,
|
|
57493
|
+
}
|
|
57494
|
+
}
|
|
57495
|
+
}
|
|
57496
|
+
|
|
56094
57497
|
impl From<HighlightStyle> for html_to_markdown_rs::HighlightStyle {
|
|
56095
57498
|
fn from(val: HighlightStyle) -> Self {
|
|
56096
57499
|
match val {
|
|
@@ -56449,6 +57852,26 @@ impl From<xberg::LayoutClass> for LayoutClass {
|
|
|
56449
57852
|
}
|
|
56450
57853
|
}
|
|
56451
57854
|
|
|
57855
|
+
#[cfg(feature = "layout-types")]
|
|
57856
|
+
impl From<LayoutDetectionModel> for xberg::LayoutDetectionModel {
|
|
57857
|
+
fn from(val: LayoutDetectionModel) -> Self {
|
|
57858
|
+
match val {
|
|
57859
|
+
LayoutDetectionModel::RtDetr => Self::RtDetr,
|
|
57860
|
+
LayoutDetectionModel::PpDocLayoutV3 => Self::PpDocLayoutV3,
|
|
57861
|
+
}
|
|
57862
|
+
}
|
|
57863
|
+
}
|
|
57864
|
+
|
|
57865
|
+
#[cfg(feature = "layout-types")]
|
|
57866
|
+
impl From<xberg::LayoutDetectionModel> for LayoutDetectionModel {
|
|
57867
|
+
fn from(val: xberg::LayoutDetectionModel) -> Self {
|
|
57868
|
+
match val {
|
|
57869
|
+
xberg::LayoutDetectionModel::RtDetr => Self::RtDetr,
|
|
57870
|
+
xberg::LayoutDetectionModel::PpDocLayoutV3 => Self::PpDocLayoutV3,
|
|
57871
|
+
}
|
|
57872
|
+
}
|
|
57873
|
+
}
|
|
57874
|
+
|
|
56452
57875
|
#[cfg(feature = "layout-types")]
|
|
56453
57876
|
impl From<LayoutStrategy> for xberg::LayoutStrategy {
|
|
56454
57877
|
fn from(val: LayoutStrategy) -> Self {
|
|
@@ -57781,32 +59204,137 @@ impl From<html_to_markdown_rs::WhitespaceMode> for WhitespaceMode {
|
|
|
57781
59204
|
}
|
|
57782
59205
|
}
|
|
57783
59206
|
|
|
57784
|
-
/// Convert a
|
|
59207
|
+
/// Convert the error a core call returned into the typed Ruby exception of its family. An error
|
|
59208
|
+
/// of a type with no converter becomes a `RuntimeError` with the message.
|
|
59209
|
+
#[allow(dead_code)]
|
|
59210
|
+
fn alef_magnus_err<E: std::fmt::Display + 'static>(e: E) -> magnus::Error {
|
|
59211
|
+
let message = e.to_string();
|
|
59212
|
+
#[allow(unused_variables)]
|
|
59213
|
+
let any: Box<dyn std::any::Any> = Box::new(e);
|
|
59214
|
+
let any = match any.downcast::<xberg::HeuristicsError>() {
|
|
59215
|
+
Ok(typed) => return heuristics_error_to_magnus_err(*typed),
|
|
59216
|
+
Err(any) => any,
|
|
59217
|
+
};
|
|
59218
|
+
let any = match any.downcast::<xberg::LoadError>() {
|
|
59219
|
+
Ok(typed) => return load_error_to_magnus_err(*typed),
|
|
59220
|
+
Err(any) => any,
|
|
59221
|
+
};
|
|
59222
|
+
let any = match any.downcast::<xberg::ResolveError>() {
|
|
59223
|
+
Ok(typed) => return resolve_error_to_magnus_err(*typed),
|
|
59224
|
+
Err(any) => any,
|
|
59225
|
+
};
|
|
59226
|
+
let any = match any.downcast::<xberg::XbergError>() {
|
|
59227
|
+
Ok(typed) => return xberg_error_to_magnus_err(*typed),
|
|
59228
|
+
Err(any) => any,
|
|
59229
|
+
};
|
|
59230
|
+
let _ = any;
|
|
59231
|
+
magnus::Error::new(
|
|
59232
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(),
|
|
59233
|
+
message,
|
|
59234
|
+
)
|
|
59235
|
+
}
|
|
59236
|
+
|
|
59237
|
+
/// Convert a `xberg::HeuristicsError` error to a typed Ruby exception.
|
|
57785
59238
|
#[allow(dead_code)]
|
|
57786
59239
|
fn heuristics_error_to_magnus_err(e: xberg::HeuristicsError) -> magnus::Error {
|
|
57787
|
-
|
|
57788
|
-
|
|
59240
|
+
use magnus::prelude::*;
|
|
59241
|
+
let message = e.to_string();
|
|
59242
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
59243
|
+
#[allow(unreachable_patterns)]
|
|
59244
|
+
let class_name = match &e {
|
|
59245
|
+
xberg::HeuristicsError::ConfigError(..) => "ConfigError",
|
|
59246
|
+
xberg::HeuristicsError::PdfAnalysisError(..) => "PdfAnalysisError",
|
|
59247
|
+
_ => "HeuristicsError",
|
|
59248
|
+
};
|
|
59249
|
+
let build = || -> Result<magnus::Error, magnus::Error> {
|
|
59250
|
+
let module = ruby.define_module("Xberg")?;
|
|
59251
|
+
let class: magnus::ExceptionClass = module.const_get(class_name)?;
|
|
59252
|
+
let exception = class.new_instance((message.as_str(),))?;
|
|
59253
|
+
Ok(magnus::Error::from(exception))
|
|
59254
|
+
};
|
|
59255
|
+
build().unwrap_or_else(|_| magnus::Error::new(ruby.exception_runtime_error(), message))
|
|
57789
59256
|
}
|
|
57790
59257
|
|
|
57791
|
-
/// Convert a `xberg::LoadError` error to a
|
|
59258
|
+
/// Convert a `xberg::LoadError` error to a typed Ruby exception.
|
|
57792
59259
|
#[allow(dead_code)]
|
|
57793
59260
|
fn load_error_to_magnus_err(e: xberg::LoadError) -> magnus::Error {
|
|
57794
|
-
|
|
57795
|
-
|
|
59261
|
+
use magnus::prelude::*;
|
|
59262
|
+
let message = e.to_string();
|
|
59263
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
59264
|
+
#[allow(unreachable_patterns)]
|
|
59265
|
+
let class_name = match &e {
|
|
59266
|
+
xberg::LoadError::Parse { .. } => "ParseError",
|
|
59267
|
+
xberg::LoadError::SchemaValidation { .. } => "SchemaValidationError",
|
|
59268
|
+
xberg::LoadError::Deserialize { .. } => "DeserializeError",
|
|
59269
|
+
xberg::LoadError::IdMismatch { .. } => "IdMismatchError",
|
|
59270
|
+
xberg::LoadError::BadMetaSchema(..) => "BadMetaSchemaError",
|
|
59271
|
+
xberg::LoadError::Io(..) => "IoError",
|
|
59272
|
+
_ => "LoadError",
|
|
59273
|
+
};
|
|
59274
|
+
let build = || -> Result<magnus::Error, magnus::Error> {
|
|
59275
|
+
let module = ruby.define_module("Xberg")?;
|
|
59276
|
+
let class: magnus::ExceptionClass = module.const_get(class_name)?;
|
|
59277
|
+
let exception = class.new_instance((message.as_str(),))?;
|
|
59278
|
+
Ok(magnus::Error::from(exception))
|
|
59279
|
+
};
|
|
59280
|
+
build().unwrap_or_else(|_| magnus::Error::new(ruby.exception_runtime_error(), message))
|
|
57796
59281
|
}
|
|
57797
59282
|
|
|
57798
|
-
/// Convert a `xberg::ResolveError` error to a
|
|
59283
|
+
/// Convert a `xberg::ResolveError` error to a typed Ruby exception.
|
|
57799
59284
|
#[allow(dead_code)]
|
|
57800
59285
|
fn resolve_error_to_magnus_err(e: xberg::ResolveError) -> magnus::Error {
|
|
57801
|
-
|
|
57802
|
-
|
|
59286
|
+
use magnus::prelude::*;
|
|
59287
|
+
let message = e.to_string();
|
|
59288
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
59289
|
+
#[allow(unreachable_patterns)]
|
|
59290
|
+
let class_name = match &e {
|
|
59291
|
+
xberg::ResolveError::SchemaNotObject => "SchemaNotObjectError",
|
|
59292
|
+
_ => "ResolveError",
|
|
59293
|
+
};
|
|
59294
|
+
let build = || -> Result<magnus::Error, magnus::Error> {
|
|
59295
|
+
let module = ruby.define_module("Xberg")?;
|
|
59296
|
+
let class: magnus::ExceptionClass = module.const_get(class_name)?;
|
|
59297
|
+
let exception = class.new_instance((message.as_str(),))?;
|
|
59298
|
+
Ok(magnus::Error::from(exception))
|
|
59299
|
+
};
|
|
59300
|
+
build().unwrap_or_else(|_| magnus::Error::new(ruby.exception_runtime_error(), message))
|
|
57803
59301
|
}
|
|
57804
59302
|
|
|
57805
|
-
/// Convert a `xberg::XbergError` error to a
|
|
59303
|
+
/// Convert a `xberg::XbergError` error to a typed Ruby exception.
|
|
57806
59304
|
#[allow(dead_code)]
|
|
57807
59305
|
fn xberg_error_to_magnus_err(e: xberg::XbergError) -> magnus::Error {
|
|
57808
|
-
|
|
57809
|
-
|
|
59306
|
+
use magnus::prelude::*;
|
|
59307
|
+
let message = e.to_string();
|
|
59308
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
59309
|
+
#[allow(unreachable_patterns)]
|
|
59310
|
+
let class_name = match &e {
|
|
59311
|
+
xberg::XbergError::Io(..) => "IoError",
|
|
59312
|
+
xberg::XbergError::Parsing { .. } => "ParsingError",
|
|
59313
|
+
xberg::XbergError::Ocr { .. } => "OcrError",
|
|
59314
|
+
xberg::XbergError::Validation { .. } => "ValidationError",
|
|
59315
|
+
xberg::XbergError::Cache { .. } => "CacheError",
|
|
59316
|
+
xberg::XbergError::ImageProcessing { .. } => "ImageProcessingError",
|
|
59317
|
+
xberg::XbergError::Serialization { .. } => "SerializationError",
|
|
59318
|
+
xberg::XbergError::MissingDependency(..) => "MissingDependencyError",
|
|
59319
|
+
xberg::XbergError::Plugin { .. } => "PluginError",
|
|
59320
|
+
xberg::XbergError::LockPoisoned(..) => "LockPoisonedError",
|
|
59321
|
+
xberg::XbergError::UnsupportedFormat(..) => "UnsupportedFormatError",
|
|
59322
|
+
xberg::XbergError::Embedding { .. } => "EmbeddingError",
|
|
59323
|
+
xberg::XbergError::Reranking { .. } => "RerankingError",
|
|
59324
|
+
xberg::XbergError::Transcription { .. } => "TranscriptionError",
|
|
59325
|
+
xberg::XbergError::Timeout { .. } => "XbergTimeoutError",
|
|
59326
|
+
xberg::XbergError::Cancelled => "CancelledError",
|
|
59327
|
+
xberg::XbergError::Security { .. } => "SecurityError",
|
|
59328
|
+
xberg::XbergError::Other(..) => "OtherError",
|
|
59329
|
+
_ => "XbergError",
|
|
59330
|
+
};
|
|
59331
|
+
let build = || -> Result<magnus::Error, magnus::Error> {
|
|
59332
|
+
let module = ruby.define_module("Xberg")?;
|
|
59333
|
+
let class: magnus::ExceptionClass = module.const_get(class_name)?;
|
|
59334
|
+
let exception = class.new_instance((message.as_str(),))?;
|
|
59335
|
+
Ok(magnus::Error::from(exception))
|
|
59336
|
+
};
|
|
59337
|
+
build().unwrap_or_else(|_| magnus::Error::new(ruby.exception_runtime_error(), message))
|
|
57810
59338
|
}
|
|
57811
59339
|
|
|
57812
59340
|
#[magnus::init]
|
|
@@ -57979,6 +59507,12 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
57979
59507
|
|
|
57980
59508
|
class.define_method("chrome_args", method!(BrowserConfig::chrome_args, 0))?;
|
|
57981
59509
|
|
|
59510
|
+
class.define_method("scroll_containers", method!(BrowserConfig::scroll_containers, 0))?;
|
|
59511
|
+
|
|
59512
|
+
class.define_method("dom_quiet_window", method!(BrowserConfig::dom_quiet_window, 0))?;
|
|
59513
|
+
|
|
59514
|
+
class.define_method("dom_quiet_cap", method!(BrowserConfig::dom_quiet_cap, 0))?;
|
|
59515
|
+
|
|
57982
59516
|
let class = module.define_class("CacheStats", ruby.class_object())?;
|
|
57983
59517
|
|
|
57984
59518
|
class.define_singleton_method("new", function!(CacheStats::new, -1))?;
|
|
@@ -58299,6 +59833,31 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
58299
59833
|
|
|
58300
59834
|
class.define_method("extract_metadata", method!(ContentConfig::extract_metadata, 0))?;
|
|
58301
59835
|
|
|
59836
|
+
class.define_method("strip_newlines", method!(ContentConfig::strip_newlines, 0))?;
|
|
59837
|
+
|
|
59838
|
+
class.define_method("bullets", method!(ContentConfig::bullets, 0))?;
|
|
59839
|
+
|
|
59840
|
+
class.define_method("list_indent_width", method!(ContentConfig::list_indent_width, 0))?;
|
|
59841
|
+
|
|
59842
|
+
class.define_method("strong_em_symbol", method!(ContentConfig::strong_em_symbol, 0))?;
|
|
59843
|
+
|
|
59844
|
+
class.define_method("compact_tables", method!(ContentConfig::compact_tables, 0))?;
|
|
59845
|
+
|
|
59846
|
+
class.define_method(
|
|
59847
|
+
"keep_inline_images_in",
|
|
59848
|
+
method!(ContentConfig::keep_inline_images_in, 0),
|
|
59849
|
+
)?;
|
|
59850
|
+
|
|
59851
|
+
class.define_method("keep_hidden", method!(ContentConfig::keep_hidden, 0))?;
|
|
59852
|
+
|
|
59853
|
+
class.define_method("expand_abbreviations", method!(ContentConfig::expand_abbreviations, 0))?;
|
|
59854
|
+
|
|
59855
|
+
class.define_method("escape_misc", method!(ContentConfig::escape_misc, 0))?;
|
|
59856
|
+
|
|
59857
|
+
class.define_method("escape_asterisks", method!(ContentConfig::escape_asterisks, 0))?;
|
|
59858
|
+
|
|
59859
|
+
class.define_method("include_icon_labels", method!(ContentConfig::include_icon_labels, 0))?;
|
|
59860
|
+
|
|
58302
59861
|
let class = module.define_class("ContentFilterConfig", ruby.class_object())?;
|
|
58303
59862
|
|
|
58304
59863
|
class.define_singleton_method("new", function!(ContentFilterConfig::new, -1))?;
|
|
@@ -58353,6 +59912,16 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
58353
59912
|
|
|
58354
59913
|
class.define_method("autolinks", method!(ConversionOptions::autolinks, 0))?;
|
|
58355
59914
|
|
|
59915
|
+
class.define_method(
|
|
59916
|
+
"expand_abbreviations",
|
|
59917
|
+
method!(ConversionOptions::expand_abbreviations, 0),
|
|
59918
|
+
)?;
|
|
59919
|
+
|
|
59920
|
+
class.define_method(
|
|
59921
|
+
"include_blockquote_citations",
|
|
59922
|
+
method!(ConversionOptions::include_blockquote_citations, 0),
|
|
59923
|
+
)?;
|
|
59924
|
+
|
|
58356
59925
|
class.define_method("default_title", method!(ConversionOptions::default_title, 0))?;
|
|
58357
59926
|
|
|
58358
59927
|
class.define_method("br_in_tables", method!(ConversionOptions::br_in_tables, 0))?;
|
|
@@ -58400,6 +59969,8 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
58400
59969
|
|
|
58401
59970
|
class.define_method("inline_data_media", method!(ConversionOptions::inline_data_media, 0))?;
|
|
58402
59971
|
|
|
59972
|
+
class.define_method("hidden_content", method!(ConversionOptions::hidden_content, 0))?;
|
|
59973
|
+
|
|
58403
59974
|
class.define_method("url_escape_style", method!(ConversionOptions::url_escape_style, 0))?;
|
|
58404
59975
|
|
|
58405
59976
|
class.define_method("link_style", method!(ConversionOptions::link_style, 0))?;
|
|
@@ -58611,6 +60182,16 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
58611
60182
|
method!(CrawlConfig::ssrf_deny_private_explicit, 0),
|
|
58612
60183
|
)?;
|
|
58613
60184
|
|
|
60185
|
+
class.define_method(
|
|
60186
|
+
"danger_accept_invalid_certs",
|
|
60187
|
+
method!(CrawlConfig::danger_accept_invalid_certs, 0),
|
|
60188
|
+
)?;
|
|
60189
|
+
|
|
60190
|
+
class.define_method(
|
|
60191
|
+
"subdomain_header_allowlist",
|
|
60192
|
+
method!(CrawlConfig::subdomain_header_allowlist, 0),
|
|
60193
|
+
)?;
|
|
60194
|
+
|
|
58614
60195
|
let class = module.define_class("CsvConfig", ruby.class_object())?;
|
|
58615
60196
|
|
|
58616
60197
|
class.define_singleton_method("new", function!(CsvConfig::new, -1))?;
|
|
@@ -59266,6 +60847,17 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
59266
60847
|
|
|
59267
60848
|
class.define_method("config", method!(ExtractInput::config, 0))?;
|
|
59268
60849
|
|
|
60850
|
+
let class = module.define_class("ExtractInputWithOptions", ruby.class_object())?;
|
|
60851
|
+
|
|
60852
|
+
class.define_singleton_method("new", function!(ExtractInputWithOptions::new, -1))?;
|
|
60853
|
+
|
|
60854
|
+
class.define_method("input", method!(ExtractInputWithOptions::input, 0))?;
|
|
60855
|
+
|
|
60856
|
+
class.define_method(
|
|
60857
|
+
"use_layout_for_markdown",
|
|
60858
|
+
method!(ExtractInputWithOptions::use_layout_for_markdown, 0),
|
|
60859
|
+
)?;
|
|
60860
|
+
|
|
59269
60861
|
let class = module.define_class("ExtractedDocument", ruby.class_object())?;
|
|
59270
60862
|
|
|
59271
60863
|
class.define_singleton_method("new", function!(ExtractedDocument::new, -1))?;
|
|
@@ -60502,6 +62094,9 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
60502
62094
|
method!(LayoutDetectionConfig::enable_chart_understanding, 0),
|
|
60503
62095
|
)?;
|
|
60504
62096
|
|
|
62097
|
+
#[cfg(feature = "layout-types")]
|
|
62098
|
+
class.define_method("model", method!(LayoutDetectionConfig::model, 0))?;
|
|
62099
|
+
|
|
60505
62100
|
let class = module.define_class("LayoutRegion", ruby.class_object())?;
|
|
60506
62101
|
|
|
60507
62102
|
class.define_singleton_method("new", function!(LayoutRegion::new, -1))?;
|
|
@@ -61046,6 +62641,11 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
61046
62641
|
method!(OcrQualityThresholds::discard_suspected_ocr_noise, 0),
|
|
61047
62642
|
)?;
|
|
61048
62643
|
|
|
62644
|
+
class.define_method(
|
|
62645
|
+
"prune_symbol_noise_lines",
|
|
62646
|
+
method!(OcrQualityThresholds::prune_symbol_noise_lines, 0),
|
|
62647
|
+
)?;
|
|
62648
|
+
|
|
61049
62649
|
class.define_method(
|
|
61050
62650
|
"min_avg_word_length",
|
|
61051
62651
|
method!(OcrQualityThresholds::min_avg_word_length, 0),
|
|
@@ -62814,12 +64414,28 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
62814
64414
|
|
|
62815
64415
|
module.define_module_function("extract_batch", function!(extract_batch_async, -1))?;
|
|
62816
64416
|
|
|
64417
|
+
module.define_module_function(
|
|
64418
|
+
"extract_batch_with_input_options",
|
|
64419
|
+
function!(extract_batch_with_input_options_async, -1),
|
|
64420
|
+
)?;
|
|
64421
|
+
|
|
64422
|
+
module.define_module_function(
|
|
64423
|
+
"extract_batch_with_input_options_json",
|
|
64424
|
+
function!(extract_batch_with_input_options_json_async, -1),
|
|
64425
|
+
)?;
|
|
64426
|
+
|
|
62817
64427
|
#[cfg(feature = "redaction")]
|
|
62818
64428
|
module.define_module_function(
|
|
62819
64429
|
"extract_with_external_redaction",
|
|
62820
64430
|
function!(extract_with_external_redaction_async, -1),
|
|
62821
64431
|
)?;
|
|
62822
64432
|
|
|
64433
|
+
#[cfg(all(feature = "pdf", feature = "layout-detection"))]
|
|
64434
|
+
module.define_module_function(
|
|
64435
|
+
"extract_with_layout_pages",
|
|
64436
|
+
function!(extract_with_layout_pages_async, 3),
|
|
64437
|
+
)?;
|
|
64438
|
+
|
|
62823
64439
|
#[cfg(feature = "markdown-footnotes")]
|
|
62824
64440
|
module.define_module_function("find_unmarked_claims", function!(find_unmarked_claims, 1))?;
|
|
62825
64441
|
|
|
@@ -62942,5 +64558,41 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
62942
64558
|
|
|
62943
64559
|
module.define_module_function("clear_tokenizer_backends", function!(clear_tokenizer_backends, 0))?;
|
|
62944
64560
|
|
|
64561
|
+
let heuristics_error_class = module.define_error("HeuristicsError", ruby.exception_standard_error())?;
|
|
64562
|
+
module.define_error("ConfigError", heuristics_error_class)?;
|
|
64563
|
+
module.define_error("PdfAnalysisError", heuristics_error_class)?;
|
|
64564
|
+
let load_error_class = module.define_error("LoadError", ruby.exception_standard_error())?;
|
|
64565
|
+
module.define_error("ParseError", load_error_class)?;
|
|
64566
|
+
module.define_error("SchemaValidationError", load_error_class)?;
|
|
64567
|
+
module.define_error("DeserializeError", load_error_class)?;
|
|
64568
|
+
module.define_error("IdMismatchError", load_error_class)?;
|
|
64569
|
+
module.define_error("BadMetaSchemaError", load_error_class)?;
|
|
64570
|
+
module.define_error("IoError", load_error_class)?;
|
|
64571
|
+
let resolve_error_class = module.define_error("ResolveError", ruby.exception_standard_error())?;
|
|
64572
|
+
module.define_error("SchemaNotObjectError", resolve_error_class)?;
|
|
64573
|
+
let xberg_error_class = module.define_error("XbergError", ruby.exception_standard_error())?;
|
|
64574
|
+
module.define_error("ParsingError", xberg_error_class)?;
|
|
64575
|
+
module.define_error("OcrError", xberg_error_class)?;
|
|
64576
|
+
module.define_error("ValidationError", xberg_error_class)?;
|
|
64577
|
+
module.define_error("CacheError", xberg_error_class)?;
|
|
64578
|
+
module.define_error("ImageProcessingError", xberg_error_class)?;
|
|
64579
|
+
module.define_error("SerializationError", xberg_error_class)?;
|
|
64580
|
+
module.define_error("MissingDependencyError", xberg_error_class)?;
|
|
64581
|
+
module.define_error("PluginError", xberg_error_class)?;
|
|
64582
|
+
module.define_error("LockPoisonedError", xberg_error_class)?;
|
|
64583
|
+
module.define_error("UnsupportedFormatError", xberg_error_class)?;
|
|
64584
|
+
module.define_error("EmbeddingError", xberg_error_class)?;
|
|
64585
|
+
module.define_error("RerankingError", xberg_error_class)?;
|
|
64586
|
+
module.define_error("TranscriptionError", xberg_error_class)?;
|
|
64587
|
+
module.define_error("XbergTimeoutError", xberg_error_class)?;
|
|
64588
|
+
module.define_error("CancelledError", xberg_error_class)?;
|
|
64589
|
+
module.define_error("SecurityError", xberg_error_class)?;
|
|
64590
|
+
module.define_error("OtherError", xberg_error_class)?;
|
|
64591
|
+
module.funcall::<_, _, magnus::Value>("module_eval", ("class HeuristicsError\n module Family; end\n include Family\n def self.===(other)\n super || (equal?(HeuristicsError) && Family === other)\n end\nend",))?;
|
|
64592
|
+
module.funcall::<_, _, magnus::Value>("module_eval", ("class LoadError\n module Family; end\n include Family\n def self.===(other)\n super || (equal?(LoadError) && Family === other)\n end\nend",))?;
|
|
64593
|
+
module.funcall::<_, _, magnus::Value>("module_eval", ("class ResolveError\n module Family; end\n include Family\n def self.===(other)\n super || (equal?(ResolveError) && Family === other)\n end\nend",))?;
|
|
64594
|
+
module.funcall::<_, _, magnus::Value>("module_eval", ("class XbergError\n module Family; end\n include Family\n def self.===(other)\n super || (equal?(XbergError) && Family === other)\n end\nend",))?;
|
|
64595
|
+
module.funcall::<_, _, magnus::Value>("module_eval", ("IoError.include(XbergError::Family)",))?;
|
|
64596
|
+
|
|
62945
64597
|
Ok(())
|
|
62946
64598
|
}
|