Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

Session对象

Implementations§

Source§

impl Session

Source

pub unsafe fn clone(&self) -> Session

克隆Session对象

§Safety

此方法不能延长Session对象的生命周期,因此不能保证克隆后的Session对象始终有效,生命周期将始终与此对象一样

Source

pub fn restart_requested(&self) -> bool

判断是否有重启Session的请求 (在PowerScript中调用了Restart函数)

Source

pub fn has_visual_object(&self) -> bool

是否创建了可视化对象 (打开了顶层窗口)

Source

pub fn process_message(&self) -> bool

处理PB消息

§Notice

开启了消息循环后,需要处理PB的消息以执行PowerScript中的Post调用

Source

pub fn has_exception(&self) -> bool

检查当前是否有异常未处理

Source

pub fn clear_exception(&self)

清除异常

Source

pub fn throw_exception(&self, exstr: impl AsPBStr) -> Result<()>

抛出PBXRuntimeError异常

§Exmaples
session.throw_exception("test");
// 使用宏
throw!(session,"this is a {}!","exception");
Source

pub fn set_prop<T, D>(&self, name: T, data: &'static D)
where T: AsPBStr, D: Sized,

与Session绑定static引用参数

Source

pub fn set_prop_ptr<T, D>(&self, name: T, data: *const D)
where T: AsPBStr, D: Sized,

与Session绑定指针参数

Source

pub fn get_prop_ptr<T, D>(&self, name: T) -> *const D
where T: AsPBStr, D: Sized,

获取Session绑定的指针参数

Source

pub unsafe fn get_prop_ref<'a, T, D>(&self, name: T) -> Option<&'a D>
where T: AsPBStr, D: Sized,

获取Session绑定的引用参数

§Safety

引用的生命周期由调用处提供,需要开发者自行保证期有效性

Source

pub unsafe fn get_prop_mut<'a, T, D>(&self, name: T) -> Option<&'a mut D>
where T: AsPBStr, D: Sized,

获取Session绑定的可变引用参数

§Safety

引用的生命周期由调用处提供,需要开发者自行保证期有效性

Source

pub fn remove_prop(&self, name: impl AsPBStr)

解绑Session参数

§Notice

如果绑定的参数内存是由Box分配的,那么需要在解绑前正确释放内存

Source

pub fn get_enum_item_value( &self, enum_name: impl AsPBStr, item_name: impl AsPBStr, ) -> pblong

获取指定名称枚举的值,不区分大小写

§Examples
// `Center!`枚举的值
session.get_enum_item_value("Aligment","Center");
Source

pub fn get_enum_item_name<'a>( &'a self, enum_name: impl AsPBStr, item_value: pblong, ) -> Option<&'a PBStr>

获取枚举值的枚举名称,不区分大小写

§Examples
let val = session.get_enum_item_value("Aligment","Center");
let name = session.get_enum_item_name("Aligment",val); //center
Source

pub fn new_user_object<'a>( &'a self, cls_name: impl AsPBStr, ) -> Result<Object<'a>>

实例化用户自定义对象

§Examples
let obj = session.new_user_object("n_cst_object");
Source

pub fn new_system_object<'a>( &'a self, cls_name: impl AsPBStr, ) -> Result<Object<'a>>

实例化系统对象

§Examples
let obj = session.new_system_object("datastore");
Source

pub fn new_object<'a>(&'a self, cls_name: impl AsPBStr) -> Result<Object<'a>>

实例化任意PB对象 (包括用户自定义对象和系统对象)

§Examples
let obj = session.new_object("n_cst_object");
let obj = session.new_object("datastore");
Source

pub fn new_array<'a>(&'a self, item_type: ValueType) -> Result<Array<'a>>

实例化变长标量一维数组

§Parameters
  • item_type 元素标量类型
§Examples
//int arr[]
let mut arr = session.new_array(ValueType::Int).unwrap();
//arr[1] = 123
arr.set_item_int(&[1],123);
Source

pub fn new_bounded_array<'a>( &'a self, item_type: ValueType, dims: &[(pblong, pblong)], ) -> Result<Array<'a>>

实例化定长标量多维数组

§Parameters
  • item_type 元素标量类型
  • dims &[(下标,上标)]
§Examples
//int arr[10]
let mut arr = session.new_bounded_array(ValueType::Int,&[(1,10)]).unwrap();
//arr[1] = 123
arr.set_item_int(&[1],123);

//int arr[2,4]
let mut arr = session.new_bounded_array(ValueType::Int,&[(1,2),(1,4)]).unwrap();
//arr[1,2] = 123
arr.set_item_int(&[1,2],123);

//int arr[1 to 5,2 to 10]
let mut arr = session.new_bounded_array(ValueType::Int,&[(1,5),(2,10)]).unwrap();
//arr[1,2] = 123
arr.set_item_int(&[1,2],123);
Source

pub fn new_user_object_array<'a>( &'a self, cls_name: impl AsPBStr, ) -> Result<Array<'a>>

实例化变长用户自定义对象一维数组

§Parameters
  • cls_name 元素对象类名
§Examples
//n_cst_test arr[]
let mut arr = session.new_user_object_array("n_cst_test").unwrap();
//arr[1] = Create n_cst_test
let obj = session.new_user_object("n_cst_test").unwrap();
arr.set_item_object(&[1],&obj);
Source

pub fn new_system_object_array<'a>( &'a self, cls_name: impl AsPBStr, ) -> Result<Array<'a>>

实例化变长系统对象一维数组

§Parameters
  • cls_name 元素对象类名
§Examples
//datastore arr[]
let mut arr = session.new_system_object_array("datastore").unwrap();
//arr[1] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1],&obj);
Source

pub fn new_object_array<'a>( &'a self, cls_name: impl AsPBStr, ) -> Result<Array<'a>>

实例化变长任意对象一维数组 (包括用户自定义对象和系统对象)

§Parameters
  • cls_name 元素对象类名
§Examples
//datastore arr[]
let mut arr = session.new_object_array("datastore").unwrap();
//arr[1] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1],&obj);
Source

pub fn new_bounded_user_object_array<'a>( &'a self, cls_name: impl AsPBStr, dims: &[(pblong, pblong)], ) -> Result<Array<'a>>

实例化定长用户自定义对象多维数组

§Parameters
  • cls_name 元素对象类名
  • dims &[(下标,上标)]
§Examples
//n_cst_test arr[10]
let mut arr = session.new_bounded_user_object_array("n_cst_test",&[(1,10)]).unwrap();
//arr[1] = Create n_cst_test
let obj = session.new_user_object("n_cst_test").unwrap();
arr.set_item_object(&[1],&obj);

//n_cst_test arr[2,4]
let mut arr = session.new_bounded_user_object_array("n_cst_test",&[(1,2),(1,4)]).unwrap();
//arr[1,2] = Create n_cst_test
let obj = session.new_user_object("n_cst_test").unwrap();
arr.set_item_object(&[1,2],&obj);

//n_cst_test arr[1 to 5,2 to 10]
let mut arr = session.new_bounded_user_object_array("n_cst_test",&[(1,5),(2,10)]).unwrap();
//arr[1,2] = Create n_cst_test
arr.set_item_object(&[1,2],&obj);
Source

pub fn new_bounded_system_object_array<'a>( &'a self, cls_name: impl AsPBStr, dims: &[(pblong, pblong)], ) -> Result<Array<'a>>

实例化定长用户自定义对象多维数组

§Parameters
  • cls_name 元素对象类名
  • dims &[(下标,上标)]
§Examples
//datastore arr[10]
let mut arr = session.new_bounded_system_object_array("datastore",&[(1,10)]).unwrap();
//arr[1] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1],&obj);

//datastore arr[2,4]
let mut arr = session.new_bounded_system_object_array("datastore",&[(1,2),(1,4)]).unwrap();
//arr[1,2] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1,2],&obj);

//datastore arr[1 to 5,2 to 10]
let mut arr = session.new_bounded_system_object_array("datastore",&[(1,5),(2,10)]).unwrap();
//arr[1,2] = Create datastore
arr.set_item_object(&[1,2],&obj);
Source

pub fn new_bounded_object_array<'a>( &'a self, cls_name: impl AsPBStr, dims: &[(pblong, pblong)], ) -> Result<Array<'a>>

实例化定长任意对象多维数组

§Parameters
  • cls_name 元素对象类名
  • dims &[(下标,上标)]
§Examples
//datastore arr[10]
let mut arr = session.new_bounded_object_array("datastore",&[(1,10)]).unwrap();
//arr[1] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1],&obj);

//datastore arr[2,4]
let mut arr = session.new_bounded_object_array("datastore",&[(1,2),(1,4)]).unwrap();
//arr[1,2] = Create datastore
let obj = session.new_user_object("datastore").unwrap();
arr.set_item_object(&[1,2],&obj);

//datastore arr[1 to 5,2 to 10]
let mut arr = session.new_bounded_object_array("datastore",&[(1,5),(2,10)]).unwrap();
//arr[1,2] = Create datastore
arr.set_item_object(&[1,2],&obj);
Source§

impl Session

Source

pub fn get_var_id(&self, name: impl AsPBStr) -> Option<FieldId>

获取全局变量ID

§Examples
let fid = session.get_var_id("gs_var").unwrap();
session.set_var_str(fid,"rust");
Source

pub fn has_var(&self, name: impl AsPBStr) -> bool

判断是否存在指定全局变量

§Examples
if session.has_var("gs_var") {
    session.set_var_str("gs_var","rust");
}
Source

pub fn get_var_type(&self, fid: impl GlobalVarId) -> ValueType

获取指定全局变量类型

§Panics

访问不存在的变量时会触发Panic

§Examples
if session.get_var_type("gs_var") == ValueType::String {
    session.set_var_str("gs_var","rust");
}
Source

pub fn is_var_null(&self, fid: impl GlobalVarId) -> bool

判断指定全局变量是否为NULL

§Panics

访问不存在的变量时会触发Panic

Source

pub fn is_var_array(&self, fid: impl GlobalVarId) -> bool

判断指定全局变量是否为数组类型

§Panics

访问不存在的变量时会触发Panic

Source

pub fn is_var_object(&self, fid: impl GlobalVarId) -> bool

判断指定全局变量是否为对象类型

§Panics

访问不存在的变量时会触发Panic

Source

pub fn get_var_int(&self, fid: impl GlobalVarId) -> Option<pbint>

获取int类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_int_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbint>

获取int类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_uint(&self, fid: impl GlobalVarId) -> Option<pbuint>

获取uint类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_uint_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbuint>

获取uint类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_long(&self, fid: impl GlobalVarId) -> Option<pblong>

获取long类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_long_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pblong>

获取long类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_ulong(&self, fid: impl GlobalVarId) -> Option<pbulong>

获取ulong类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_ulong_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbulong>

获取ulong类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_longlong(&self, fid: impl GlobalVarId) -> Option<pblonglong>

获取longlong类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_longlong_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pblonglong>

获取longlong类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_real(&self, fid: impl GlobalVarId) -> Option<pbreal>

获取real类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_real_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbreal>

获取real类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_double(&self, fid: impl GlobalVarId) -> Option<pbdouble>

获取double类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_double_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbdouble>

获取double类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_dec(&self, fid: impl GlobalVarId) -> Option<Decimal>

获取decimal类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_dec_unchecked( &self, fid: impl GlobalVarId, ) -> Option<Decimal>

获取decimal类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub unsafe fn get_var_str<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<&'a PBStr>

获取string类型全局变量的引用

§Panics

访问不存在的变量或类型不匹配时会触发Panic

§Safety

引用类型不能保证始终有效,详情请阅读内存安全说明

Source

pub unsafe fn get_var_str_unchecked<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<&'a PBStr>

获取string类型全局变量的引用,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety
  • 类型不兼容时可能会出现未定义行为
  • 引用类型不能保证始终有效,详情请阅读内存安全说明
Source

pub fn get_var_string(&self, fid: impl GlobalVarId) -> Option<PBString>

获取string类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_string_unchecked( &self, fid: impl GlobalVarId, ) -> Option<PBString>

获取string类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_bool(&self, fid: impl GlobalVarId) -> Option<bool>

获取boolean类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_bool_unchecked( &self, fid: impl GlobalVarId, ) -> Option<bool>

获取boolean类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub unsafe fn get_var_blob<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<&'a [u8]>

获取blob类型全局变量的引用

§Panics

访问不存在的变量或类型不匹配时会触发Panic

§Safety

引用类型不能保证始终有效,详情请阅读内存安全说明

Source

pub unsafe fn get_var_blob_unchecked<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<&'a [u8]>

获取blob类型全局变量的引用,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety
  • 类型不兼容时可能会出现未定义行为
  • 引用类型不能保证始终有效,详情请阅读内存安全说明
Source

pub fn get_var_date(&self, fid: impl GlobalVarId) -> Option<NaiveDate>

获取date类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_date_unchecked( &self, fid: impl GlobalVarId, ) -> Option<NaiveDate>

获取date类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_time(&self, fid: impl GlobalVarId) -> Option<NaiveTime>

获取time类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_time_unchecked( &self, fid: impl GlobalVarId, ) -> Option<NaiveTime>

获取time类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_datetime(&self, fid: impl GlobalVarId) -> Option<NaiveDateTime>

获取datetime类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_datetime_unchecked( &self, fid: impl GlobalVarId, ) -> Option<NaiveDateTime>

获取datetime类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_char(&self, fid: impl GlobalVarId) -> Option<WideChar>

获取char类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_char_unchecked( &self, fid: impl GlobalVarId, ) -> Option<WideChar>

获取char类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn get_var_byte(&self, fid: impl GlobalVarId) -> Option<pbbyte>

获取byte类型全局变量值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn get_var_byte_unchecked( &self, fid: impl GlobalVarId, ) -> Option<pbbyte>

获取byte类型全局变量值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub unsafe fn get_var_object<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Object<'a>>

获取对象类型全局变量的引用

§Panics

访问不存在的变量或类型不匹配时会触发Panic

§Safety

引用类型不能保证始终有效,详情请阅读内存安全说明

Source

pub unsafe fn get_var_object_unchecked<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Object<'a>>

获取对象类型全局变量的引用,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety
  • 类型不兼容时可能会出现未定义行为
  • 引用类型不能保证始终有效,详情请阅读内存安全说明
Source

pub unsafe fn get_var_array<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Array<'a>>

获取数组类型全局变量的引用

§Panics

访问不存在的变量或类型不匹配时会触发Panic

§Safety

引用类型不能保证始终有效,详情请阅读内存安全说明

Source

pub unsafe fn get_var_array_unchecked<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Array<'a>>

获取数组类型全局变量的引用,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety
  • 类型不兼容时可能会出现未定义行为
  • 引用类型不能保证始终有效,详情请阅读内存安全说明
Source

pub unsafe fn get_var_any<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Value<'a>>

获取any类型全局变量的引用

§Panics

访问不存在的变量或类型不匹配时会触发Panic

§Safety

引用类型不能保证始终有效,详情请阅读内存安全说明

Source

pub unsafe fn get_var_any_unchecked<'a>( &'a self, fid: impl GlobalVarId, ) -> Option<Value<'a>>

获取any类型全局变量的引用,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety
  • 类型不兼容时可能会出现未定义行为
  • 引用类型不能保证始终有效,详情请阅读内存安全说明
Source

pub fn set_var_to_null(&self, fid: impl GlobalVarId)

设置全局变量的值为NULL

§Panics

访问不存在的变量时会触发Panic

Source

pub fn set_var_int(&mut self, fid: impl GlobalVarId, value: pbint) -> Result<()>

设置int类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_int_unchecked( &mut self, fid: impl GlobalVarId, value: pbint, ) -> Result<()>

设置int类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_uint( &mut self, fid: impl GlobalVarId, value: pbuint, ) -> Result<()>

设置uint类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_uint_unchecked( &mut self, fid: impl GlobalVarId, value: pbuint, ) -> Result<()>

设置uint类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_long( &mut self, fid: impl GlobalVarId, value: pblong, ) -> Result<()>

设置long类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_long_unchecked( &mut self, fid: impl GlobalVarId, value: pblong, ) -> Result<()>

设置long类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_ulong( &mut self, fid: impl GlobalVarId, value: pbulong, ) -> Result<()>

设置ulong类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_ulong_unchecked( &mut self, fid: impl GlobalVarId, value: pbulong, ) -> Result<()>

设置ulong类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_longlong( &mut self, fid: impl GlobalVarId, value: pblonglong, ) -> Result<()>

设置longlong类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_longlong_unchecked( &mut self, fid: impl GlobalVarId, value: pblonglong, ) -> Result<()>

设置longlong类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_real( &mut self, fid: impl GlobalVarId, value: pbreal, ) -> Result<()>

设置real类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_real_unchecked( &mut self, fid: impl GlobalVarId, value: pbreal, ) -> Result<()>

设置real类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_double( &mut self, fid: impl GlobalVarId, value: pbdouble, ) -> Result<()>

设置double类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_double_unchecked( &mut self, fid: impl GlobalVarId, value: pbdouble, ) -> Result<()>

设置double类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_dec( &mut self, fid: impl GlobalVarId, value: Decimal, ) -> Result<()>

设置decimal类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_dec_unchecked( &mut self, fid: impl GlobalVarId, value: Decimal, ) -> Result<()>

设置decimal类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_str( &mut self, fid: impl GlobalVarId, value: impl AsPBStr, ) -> Result<()>

设置string类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_str_unchecked( &mut self, fid: impl GlobalVarId, value: impl AsPBStr, ) -> Result<()>

设置string类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_bool(&mut self, fid: impl GlobalVarId, value: bool) -> Result<()>

设置boolean类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_bool_unchecked( &mut self, fid: impl GlobalVarId, value: bool, ) -> Result<()>

设置boolean类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_blob( &mut self, fid: impl GlobalVarId, value: impl AsRef<[u8]>, ) -> Result<()>

设置blob类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_blob_unchecked( &mut self, fid: impl GlobalVarId, value: impl AsRef<[u8]>, ) -> Result<()>

设置blob类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_date( &mut self, fid: impl GlobalVarId, value: NaiveDate, ) -> Result<()>

设置date类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_date_unchecked( &mut self, fid: impl GlobalVarId, value: NaiveDate, ) -> Result<()>

设置date类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_time( &mut self, fid: impl GlobalVarId, value: NaiveTime, ) -> Result<()>

设置time类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_time_unchecked( &mut self, fid: impl GlobalVarId, value: NaiveTime, ) -> Result<()>

设置time类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_datetime( &mut self, fid: impl GlobalVarId, value: NaiveDateTime, ) -> Result<()>

设置datetime类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_datetime_unchecked( &mut self, fid: impl GlobalVarId, value: NaiveDateTime, ) -> Result<()>

设置datetime类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_char( &mut self, fid: impl GlobalVarId, value: WideChar, ) -> Result<()>

设置char类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_char_unchecked( &mut self, fid: impl GlobalVarId, value: WideChar, ) -> Result<()>

设置char类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_byte( &mut self, fid: impl GlobalVarId, value: pbbyte, ) -> Result<()>

设置byte类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_byte_unchecked( &mut self, fid: impl GlobalVarId, value: pbbyte, ) -> Result<()>

设置byte类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_object( &mut self, fid: impl GlobalVarId, value: &Object<'_>, ) -> Result<()>

设置对象类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_object_unchecked( &mut self, fid: impl GlobalVarId, value: &Object<'_>, ) -> Result<()>

设置对象类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source

pub fn set_var_array( &mut self, fid: impl GlobalVarId, value: &Array<'_>, ) -> Result<()>

设置数组类型全局变量的值

§Panics

访问不存在的变量或类型不匹配时会触发Panic

Source

pub unsafe fn set_var_array_unchecked( &mut self, fid: impl GlobalVarId, value: &Array<'_>, ) -> Result<()>

设置数组类型全局变量的值,不检查类型

§Panics

访问不存在的变量时会触发Panic

§Safety

类型不兼容时可能会出现未定义行为

Source§

impl Session

Source

pub fn get_user_function_id( &self, name: impl AsMethodName, ) -> Option<GlobalFunctionId>

获取用户定义全局函数ID

§Examples
let fid = session.get_user_function_id("gf_test").unwrap();
let invoker = session.begin_invoke_function(fid).unwrap();
invoker.invoke();
Source

pub fn get_system_function_id( &self, name: impl AsMethodName, ) -> Option<GlobalFunctionId>

获取系统全局函数ID

§Examples
let fid = session.get_system_function_id(("MessageBox","ISS")).unwrap();
let invoker = session.begin_invoke_function(fid).unwrap();
invoker.arg(0).set_str("title");
invoker.arg(1).set_str("content");
invoker.invoke();
Source

pub fn get_function_id( &self, name: impl AsMethodName, ) -> Option<GlobalFunctionId>

获取任意全局函数ID

§Examples
let fid = session.get_function_id(("MessageBox","ISS")).unwrap();
let invoker = session.begin_invoke_function(fid).unwrap();
invoker.arg(0).set_str("title");
invoker.arg(1).set_str("content");
invoker.invoke();
Source

pub fn invoke_function<F, R>( &self, mid: impl AsGlobalFunctionId, arg_cb: F, ) -> Result<R>
where F: FnOnce(Arguments<'_>) -> Result<()>, R: FromValueOwned,

调用全局函数

§Examples
let rv: pbint = session.invoke_function(("MessageBox","ISS"),pbargs!["title","content"]).unwrap();
Examples found in repository?
examples/vm.rs (line 6)
3fn main() {
4    let vm = VM::new(r#"C:\Program Files (x86)\Appeon\Shared\PowerBuilder\PBVM190.DLL"#).unwrap();
5    let session = vm.new_session("pbrs", &[r#"pbrs\pbw\pbrs.pbl"#]).unwrap();
6    let rv: String = session.invoke_function("gf_pbtest", pbargs!["test vm"]).unwrap();
7    println!("rv: {}", rv);
8    let rv: pbint = session.invoke_function(("MessageBox", "ISS"), pbargs!["title", "content"]).unwrap();
9    println!("rv: {}", rv);
10}
Source

pub fn begin_invoke_function<'a>( &'a self, mid: impl AsGlobalFunctionId, ) -> Result<Invoker<GlobalFunction<'a>>>

初始化全局函数调用上下文

§Examples
let invoker = session.begin_invoke_function(("MessageBox","ISS")).unwrap();
invoker.arg(0).set_str("title");
invoker.arg(1).set_str("content");
invoker.invoke();

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.