std.winrt
COM/WinRT init, activation, HSTRING; windows only (ole32, combase)
CO_MULTITHREADED
Section titled “CO_MULTITHREADED”pub CO_MULTITHREADED :: 0CO_APARTMENTTHREADED
Section titled “CO_APARTMENTTHREADED”pub CO_APARTMENTTHREADED :: 2CLSCTX_INPROC_SERVER
Section titled “CLSCTX_INPROC_SERVER”pub CLSCTX_INPROC_SERVER :: 1the usual context for co_create_instance
co_initialize
Section titled “co_initialize”pub co_initialize :: fn(mode: u32) -> void ! ComErrorthis thread only; S_FALSE too owes a co_uninitialize on the same thread
.changed_mode if the thread already initialised the other way
co_uninitialize
Section titled “co_uninitialize”pub co_uninitialize :: fn()undoes one co_initialize, same thread
co_create_instance
Section titled “co_create_instance”pub co_create_instance :: fn(clsid: *const Guid, context: u32, iid: *const Guid, out: **void) -> i32*out has one ref to release, null on failure; context is a CLSCTX value
co_task_mem_free
Section titled “co_task_mem_free”pub co_task_mem_free :: fn(p: ?*void)COM task allocator memory, e.g. the IInspectable.get_iids array
new_guid
Section titled “new_guid”pub new_guid :: fn() -> Guid ! ComErrorCoCreateGuid, random (RFC 4122 v4)
RO_SINGLETHREADED
Section titled “RO_SINGLETHREADED”pub RO_SINGLETHREADED :: 0RO_MULTITHREADED
Section titled “RO_MULTITHREADED”pub RO_MULTITHREADED :: 1ro_initialize
Section titled “ro_initialize”pub ro_initialize :: fn(kind: i32) -> void ! ComErrorthis thread only; S_FALSE too owes a ro_uninitialize on the same thread
.changed_mode if the thread already initialised the other way
ro_uninitialize
Section titled “ro_uninitialize”pub ro_uninitialize :: fn()undoes one ro_initialize, same thread
activation_factory
Section titled “activation_factory”pub activation_factory :: fn(class_id: usize, iid: *const Guid) -> *IUnknown ! ComErrorclass_id is an HSTRING; owned ref, release it; .class_not_registered if unknown
activate_instance
Section titled “activate_instance”pub activate_instance :: fn(class_id: usize) -> *IInspectable ! ComErrordefault ctor; owned ref
HString
Section titled “HString”pub HString :: struct { h: usize,}owned; release once, never release two copies of one
HString.release
Section titled “HString.release”pub release :: fn(self: *Self)safe to call twice or on an empty string
HString.len
Section titled “HString.len”pub len :: fn(self: *const Self) -> usizeUTF-16 code units
HString.is_empty
Section titled “HString.is_empty”pub is_empty :: fn(self: *const Self) -> boolHString.units
Section titled “HString.units”pub units :: fn(self: *const Self) -> []const u16borrowed, valid until release(); no NUL in the slice
HString.duplicate
Section titled “HString.duplicate”pub duplicate :: fn(self: *const Self) -> HString ! ComErrorcheap second owned ref; release both
HString.eq
Section titled “HString.eq”pub eq :: fn(self: *const Self, other: *const HString) -> boolordinal, case-sensitive
HString.to_utf8
Section titled “HString.to_utf8”pub to_utf8 :: fn(self: *const Self, out: []u8) -> usize ! utf16::Utf16Error.invalid_utf16 or .buffer_too_small; size it with utf16::utf8_len(self.units())
hstring
Section titled “hstring”pub hstring :: fn(units: []const u16) -> HString ! ComErrorowned copy, may be empty or hold zeros; .out_of_memory if the OS can’t allocate
hstring_from_utf8
Section titled “hstring_from_utf8”pub hstring_from_utf8 :: fn(text: []const u8, scratch: []u16) -> HString ! utf16::Utf16Errorscratch needs utf16_len(text) units, free after; .invalid_utf8, .buffer_too_small
HStringRef
Section titled “HStringRef”pub HStringRef :: struct { header: [3]u64, h: usize,}borrowed HSTRING, no alloc, nothing to release
don’t move or copy after init(); the UTF-16 buffer must outlive h
header: HSTRING_HEADER, 24 bytesh: the handle; valid after init()
HStringRef.init
Section titled “HStringRef.init”pub init :: fn(self: *Self, z: []const u16) -> void ! ComErrorz must end in one 0 unit (not part of the string), else .invalid_arg