rust_macios/natural_language/
nl_model_configuration.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::{NSIndexSet, UInt},
5 object,
6 objective_c_runtime::{
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10 utils::to_optional,
11};
12
13use super::NLLanguage;
14
15#[derive(Debug)]
17#[repr(i64)]
18pub enum NLModelType {
19 Classifier,
21 Sequence,
23}
24
25object! {
26 unsafe pub struct NLModelConfiguration;
28}
29
30#[interface_impl(NSObject)]
31impl NLModelConfiguration {
32 #[property]
37 pub fn language(&self) -> Option<NLLanguage> {
38 unsafe { to_optional(msg_send![self.m_self(), language]) }
39 }
40
41 #[property]
43 pub fn revision(&self) -> UInt {
44 unsafe { msg_send![self.m_self(), revision] }
45 }
46
47 #[method]
49 pub fn supported_revisions_for_type(r#type: NLModelType) -> NSIndexSet {
50 unsafe {
51 NSIndexSet::from_id(msg_send![
52 Self::m_class(),
53 supportedRevisionsForType: r#type
54 ])
55 }
56 }
57
58 #[method]
60 pub fn current_revision_for_type(r#type: NLModelType) -> UInt {
61 unsafe { msg_send![Self::m_class(), currentRevisionForType: r#type] }
62 }
63
64 #[property]
66 pub fn ml_type(&self) -> NLModelType {
67 unsafe { msg_send![self.m_self(), type] }
68 }
69}