1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use ;
use ptr;
/// Calls a function and passes an optional string.
///
/// `f` is the function. `s` is the string.
///
/// # Errors
/// Any error returned by `f` (encoded as a negative integer) is returned by this function.
///
/// # Safety
/// `f` must be safe to call with a string pointer/length pair or with a null pointer and zero
/// length.
pub unsafe
/// Calls a function that accepts a buffer pointer/length, passes null, and returns the needed
/// buffer length.
///
/// `f` is the buffer-writing function.
///
/// # Errors
/// Any error returned by `f` (encoded as a negative integer) is returned by this function.
///
/// # Safety
/// `f` must be safe to call with a null pointer and zero length.
pub unsafe
/// Calls a function that accepts a buffer pointer/length, passes a slice, and returns the
/// written-to portion of the buffer.
///
/// `f` is the buffer-writing function. `buf` is the buffer.
///
/// # Errors
/// Any error returned by `f` (encoded as a negative integer) is returned by this function.
///
/// # Safety
/// `f` must be safe to call with a buffer pointer and length, and must return the number of bytes
/// written into the buffer.
pub unsafe
/// Calls a function that accepts a buffer pointer/length, passes a slice, and returns the
/// written-to portion of that buffer as a string.
///
/// `f` is the buffer-writing function. `buf` is the buffer.
///
/// # Errors
/// Any error returned by `f` (encoded as a negative integer) is returned by this function.
///
/// # Safety
/// In addition to the requirements specified by [`call_buffer`](call_buffer), the data written
/// into the buffer by `f` must be UTF-8.
pub unsafe