bare::ffi
이 페이지의 내용
API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.
C's types (types, also in the prelude), errno
(errno), Nabi values C holds (handle), NUL-terminated C strings
(wide: wchar_t ones), loading shared libraries (library); wit
is what the WIT bindings run on; objc, Objective-C objects, exists
only on Apple targets.
CStr and CString keep their bytes, NUL included, in one str
object, so as_ptr holds as str::as_ptr does.
CStr::from_ptr copies.
Modules
errnothe C library's errno and Windows'GetLastErroras the last#[errno]call left them.handleNabi values C code holds as avoid*.libraryshared libraries loaded at run time:dlopenon Unix,LoadLibraryWon Windows.objcObjective-C objects on Apple targets.typesC's integer and float types under their C names, as the target's C compiler sizes them.wideNUL-terminatedwchar_tstrings: UTF-16 on Windows (theWAPIs), one unit per char (UTF-32) elsewhere.witwhat the generated WIT bindings run on: linear-memory access at canonical ABI addresses (i32), the blocks strings and lists lower into, resource handles anderror-context.
Re-exports
errno::{errno, last_error, set_errno, set_last_error}Source
pub use errno::{errno, last_error, set_errno, set_last_error}errnoerrno as the last#[errno]call on this thread left it.last_errorWindows'GetLastErroras the last#[errno]call on this thread left it; 0 elsewhere.set_errnoSet errno, both the saved value and the C library's (for C functions that only report errors through it, such asstrtol: set 0 first).set_last_errorSet the savedGetLastErrorvalue and, on Windows, the thread's own (SetLastError).
handle::HandleSource
pub use handle::HandleHandleA Nabi value of typeTthat C holds as avoid*.
library::{Library, LoadError, SymbolError}Source
pub use library::{Library, LoadError, SymbolError}LibraryA loaded shared library, or the program itself (Library::this).LoadErrorSymbolErrorA library has no symbol of that name (Library::symbol).
wide::{WideCStr, WideCString}Source
pub use wide::{WideCStr, WideCString}WideCStrA NUL-terminatedwchar_tstring.WideCStringAn owned NUL-terminatedwchar_tstring.
Structs
NulErrorSource
pub struct NulErrorThe byte offset of the NUL (from
WideCString::new, its unit index).What went wrong, for display.
FromBytesUntilNulErrorSource
pub struct FromBytesUntilNulErrorBytes with no NUL at all (CStr::from_bytes_until_nul).
What went wrong, for display.
CStrSource
pub struct CStrA NUL-terminated string.
The C string at
p, copied up to its NUL;nonefor a null pointer.Safety:
pmust be null or point at a live NUL-terminated string.
Sourcepub const fn from_bytes_with_nul<B: AsBytes>(§bytes: B) throws (FromBytesWithNulError) -> CStr byteswhen the last one is the only NUL.
Sourcepub const fn from_bytes_until_nul<B: AsBytes>(§bytes: B) throws (FromBytesUntilNulError) -> CStr The bytes up to the first NUL, which must be there; the rest is ignored (a fixed-size C buffer).
A pointer to the first byte, for C; valid while
selfis alive.The bytes without the NUL.
The bytes with the trailing NUL.
The bytes before the NUL as a
str; throws if they are not UTF-8.Bytes before the NUL.
CStringSource
pub struct CStringAn owned NUL-terminated string.
bytesand a NUL; throws ifbyteshas a NUL of its own. Astrgives its UTF-8.The borrowed C string (with its NUL), valid while
selfis alive.A pointer to the first byte, for C; valid while
selfis alive.The bytes without the NUL.
The bytes with the trailing NUL.
Enums
FromBytesWithNulErrorSource
pub enum FromBytesWithNulErrorBytes that are not one C string (CStr::from_bytes_with_nul).
A NUL before the last byte, at
position.The last byte is not a NUL (or there is none).
What went wrong, for display.