tinkerforge/bindings/red_brick.rs
1/* ***********************************************************
2 * This file was automatically generated on 2024-02-27. *
3 * *
4 * Rust Bindings Version 2.0.21 *
5 * *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link *
8 * to the generators git repository on tinkerforge.com *
9 *************************************************************/
10
11//! Executes user programs and controls other Bricks/Bricklets standalone.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricks/RED_Brick_Rust.html).
14use crate::{
15 byte_converter::*,
16 converting_callback_receiver::ConvertingCallbackReceiver,
17 converting_receiver::{BrickletError, ConvertingReceiver},
18 device::*,
19 ip_connection::GetRequestSender,
20};
21pub enum RedBrickFunction {
22 CreateSession,
23 ExpireSession,
24 ExpireSessionUnchecked,
25 KeepSessionAlive,
26 ReleaseObject,
27 ReleaseObjectUnchecked,
28 AllocateString,
29 TruncateString,
30 GetStringLength,
31 SetStringChunk,
32 GetStringChunk,
33 AllocateList,
34 GetListLength,
35 GetListItem,
36 AppendToList,
37 RemoveFromList,
38 OpenFile,
39 CreatePipe,
40 GetFileInfo,
41 ReadFile,
42 ReadFileAsync,
43 AbortAsyncFileRead,
44 WriteFile,
45 WriteFileUnchecked,
46 WriteFileAsync,
47 SetFilePosition,
48 GetFilePosition,
49 SetFileEvents,
50 GetFileEvents,
51 OpenDirectory,
52 GetDirectoryName,
53 GetNextDirectoryEntry,
54 RewindDirectory,
55 CreateDirectory,
56 GetProcesses,
57 SpawnProcess,
58 KillProcess,
59 GetProcessCommand,
60 GetProcessIdentity,
61 GetProcessStdio,
62 GetProcessState,
63 GetPrograms,
64 DefineProgram,
65 PurgeProgram,
66 GetProgramIdentifier,
67 GetProgramRootDirectory,
68 SetProgramCommand,
69 GetProgramCommand,
70 SetProgramStdioRedirection,
71 GetProgramStdioRedirection,
72 SetProgramSchedule,
73 GetProgramSchedule,
74 GetProgramSchedulerState,
75 ContinueProgramSchedule,
76 StartProgram,
77 GetLastSpawnedProgramProcess,
78 GetCustomProgramOptionNames,
79 SetCustomProgramOptionValue,
80 GetCustomProgramOptionValue,
81 RemoveCustomProgramOption,
82 GetIdentity,
83 CallbackAsyncFileRead,
84 CallbackAsyncFileWrite,
85 CallbackFileEventsOccurred,
86 CallbackProcessStateChanged,
87 CallbackProgramSchedulerStateChanged,
88 CallbackProgramProcessSpawned,
89}
90impl From<RedBrickFunction> for u8 {
91 fn from(fun: RedBrickFunction) -> Self {
92 match fun {
93 RedBrickFunction::CreateSession => 1,
94 RedBrickFunction::ExpireSession => 2,
95 RedBrickFunction::ExpireSessionUnchecked => 3,
96 RedBrickFunction::KeepSessionAlive => 4,
97 RedBrickFunction::ReleaseObject => 5,
98 RedBrickFunction::ReleaseObjectUnchecked => 6,
99 RedBrickFunction::AllocateString => 7,
100 RedBrickFunction::TruncateString => 8,
101 RedBrickFunction::GetStringLength => 9,
102 RedBrickFunction::SetStringChunk => 10,
103 RedBrickFunction::GetStringChunk => 11,
104 RedBrickFunction::AllocateList => 12,
105 RedBrickFunction::GetListLength => 13,
106 RedBrickFunction::GetListItem => 14,
107 RedBrickFunction::AppendToList => 15,
108 RedBrickFunction::RemoveFromList => 16,
109 RedBrickFunction::OpenFile => 17,
110 RedBrickFunction::CreatePipe => 18,
111 RedBrickFunction::GetFileInfo => 19,
112 RedBrickFunction::ReadFile => 20,
113 RedBrickFunction::ReadFileAsync => 21,
114 RedBrickFunction::AbortAsyncFileRead => 22,
115 RedBrickFunction::WriteFile => 23,
116 RedBrickFunction::WriteFileUnchecked => 24,
117 RedBrickFunction::WriteFileAsync => 25,
118 RedBrickFunction::SetFilePosition => 26,
119 RedBrickFunction::GetFilePosition => 27,
120 RedBrickFunction::SetFileEvents => 28,
121 RedBrickFunction::GetFileEvents => 29,
122 RedBrickFunction::OpenDirectory => 33,
123 RedBrickFunction::GetDirectoryName => 34,
124 RedBrickFunction::GetNextDirectoryEntry => 35,
125 RedBrickFunction::RewindDirectory => 36,
126 RedBrickFunction::CreateDirectory => 37,
127 RedBrickFunction::GetProcesses => 38,
128 RedBrickFunction::SpawnProcess => 39,
129 RedBrickFunction::KillProcess => 40,
130 RedBrickFunction::GetProcessCommand => 41,
131 RedBrickFunction::GetProcessIdentity => 42,
132 RedBrickFunction::GetProcessStdio => 43,
133 RedBrickFunction::GetProcessState => 44,
134 RedBrickFunction::GetPrograms => 46,
135 RedBrickFunction::DefineProgram => 47,
136 RedBrickFunction::PurgeProgram => 48,
137 RedBrickFunction::GetProgramIdentifier => 49,
138 RedBrickFunction::GetProgramRootDirectory => 50,
139 RedBrickFunction::SetProgramCommand => 51,
140 RedBrickFunction::GetProgramCommand => 52,
141 RedBrickFunction::SetProgramStdioRedirection => 53,
142 RedBrickFunction::GetProgramStdioRedirection => 54,
143 RedBrickFunction::SetProgramSchedule => 55,
144 RedBrickFunction::GetProgramSchedule => 56,
145 RedBrickFunction::GetProgramSchedulerState => 57,
146 RedBrickFunction::ContinueProgramSchedule => 58,
147 RedBrickFunction::StartProgram => 59,
148 RedBrickFunction::GetLastSpawnedProgramProcess => 60,
149 RedBrickFunction::GetCustomProgramOptionNames => 61,
150 RedBrickFunction::SetCustomProgramOptionValue => 62,
151 RedBrickFunction::GetCustomProgramOptionValue => 63,
152 RedBrickFunction::RemoveCustomProgramOption => 64,
153 RedBrickFunction::GetIdentity => 255,
154 RedBrickFunction::CallbackAsyncFileRead => 30,
155 RedBrickFunction::CallbackAsyncFileWrite => 31,
156 RedBrickFunction::CallbackFileEventsOccurred => 32,
157 RedBrickFunction::CallbackProcessStateChanged => 45,
158 RedBrickFunction::CallbackProgramSchedulerStateChanged => 65,
159 RedBrickFunction::CallbackProgramProcessSpawned => 66,
160 }
161 }
162}
163pub const RED_BRICK_ERROR_CODE_SUCCESS: u8 = 0;
164pub const RED_BRICK_ERROR_CODE_UNKNOWN_ERROR: u8 = 1;
165pub const RED_BRICK_ERROR_CODE_INVALID_OPERATION: u8 = 2;
166pub const RED_BRICK_ERROR_CODE_OPERATION_ABORTED: u8 = 3;
167pub const RED_BRICK_ERROR_CODE_INTERNAL_ERROR: u8 = 4;
168pub const RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID: u8 = 5;
169pub const RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID: u8 = 6;
170pub const RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID: u8 = 7;
171pub const RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID: u8 = 8;
172pub const RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED: u8 = 9;
173pub const RED_BRICK_ERROR_CODE_NO_MORE_DATA: u8 = 10;
174pub const RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE: u8 = 11;
175pub const RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED: u8 = 12;
176pub const RED_BRICK_ERROR_CODE_INVALID_PARAMETER: u8 = 128;
177pub const RED_BRICK_ERROR_CODE_NO_FREE_MEMORY: u8 = 129;
178pub const RED_BRICK_ERROR_CODE_NO_FREE_SPACE: u8 = 130;
179pub const RED_BRICK_ERROR_CODE_ACCESS_DENIED: u8 = 121;
180pub const RED_BRICK_ERROR_CODE_ALREADY_EXISTS: u8 = 132;
181pub const RED_BRICK_ERROR_CODE_DOES_NOT_EXIST: u8 = 133;
182pub const RED_BRICK_ERROR_CODE_INTERRUPTED: u8 = 134;
183pub const RED_BRICK_ERROR_CODE_IS_DIRECTORY: u8 = 135;
184pub const RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY: u8 = 136;
185pub const RED_BRICK_ERROR_CODE_WOULD_BLOCK: u8 = 137;
186pub const RED_BRICK_ERROR_CODE_OVERFLOW: u8 = 138;
187pub const RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR: u8 = 139;
188pub const RED_BRICK_ERROR_CODE_OUT_OF_RANGE: u8 = 140;
189pub const RED_BRICK_ERROR_CODE_NAME_TOO_LONG: u8 = 141;
190pub const RED_BRICK_ERROR_CODE_INVALID_SEEK: u8 = 142;
191pub const RED_BRICK_ERROR_CODE_NOT_SUPPORTED: u8 = 143;
192pub const RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES: u8 = 144;
193pub const RED_BRICK_OBJECT_TYPE_STRING: u8 = 0;
194pub const RED_BRICK_OBJECT_TYPE_LIST: u8 = 1;
195pub const RED_BRICK_OBJECT_TYPE_FILE: u8 = 2;
196pub const RED_BRICK_OBJECT_TYPE_DIRECTORY: u8 = 3;
197pub const RED_BRICK_OBJECT_TYPE_PROCESS: u8 = 4;
198pub const RED_BRICK_OBJECT_TYPE_PROGRAM: u8 = 5;
199pub const RED_BRICK_FILE_FLAG_READ_ONLY: u32 = 1;
200pub const RED_BRICK_FILE_FLAG_WRITE_ONLY: u32 = 2;
201pub const RED_BRICK_FILE_FLAG_READ_WRITE: u32 = 4;
202pub const RED_BRICK_FILE_FLAG_APPEND: u32 = 8;
203pub const RED_BRICK_FILE_FLAG_CREATE: u32 = 16;
204pub const RED_BRICK_FILE_FLAG_EXCLUSIVE: u32 = 32;
205pub const RED_BRICK_FILE_FLAG_NON_BLOCKING: u32 = 64;
206pub const RED_BRICK_FILE_FLAG_TRUNCATE: u32 = 128;
207pub const RED_BRICK_FILE_FLAG_TEMPORARY: u32 = 256;
208pub const RED_BRICK_FILE_FLAG_REPLACE: u32 = 512;
209pub const RED_BRICK_FILE_PERMISSION_USER_ALL: u16 = 448;
210pub const RED_BRICK_FILE_PERMISSION_USER_READ: u16 = 256;
211pub const RED_BRICK_FILE_PERMISSION_USER_WRITE: u16 = 128;
212pub const RED_BRICK_FILE_PERMISSION_USER_EXECUTE: u16 = 64;
213pub const RED_BRICK_FILE_PERMISSION_GROUP_ALL: u16 = 56;
214pub const RED_BRICK_FILE_PERMISSION_GROUP_READ: u16 = 32;
215pub const RED_BRICK_FILE_PERMISSION_GROUP_WRITE: u16 = 16;
216pub const RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE: u16 = 8;
217pub const RED_BRICK_FILE_PERMISSION_OTHERS_ALL: u16 = 7;
218pub const RED_BRICK_FILE_PERMISSION_OTHERS_READ: u16 = 4;
219pub const RED_BRICK_FILE_PERMISSION_OTHERS_WRITE: u16 = 2;
220pub const RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE: u16 = 1;
221pub const RED_BRICK_PIPE_FLAG_NON_BLOCKING_READ: u32 = 1;
222pub const RED_BRICK_PIPE_FLAG_NON_BLOCKING_WRITE: u32 = 2;
223pub const RED_BRICK_FILE_TYPE_UNKNOWN: u8 = 0;
224pub const RED_BRICK_FILE_TYPE_REGULAR: u8 = 1;
225pub const RED_BRICK_FILE_TYPE_DIRECTORY: u8 = 2;
226pub const RED_BRICK_FILE_TYPE_CHARACTER: u8 = 3;
227pub const RED_BRICK_FILE_TYPE_BLOCK: u8 = 4;
228pub const RED_BRICK_FILE_TYPE_FIFO: u8 = 5;
229pub const RED_BRICK_FILE_TYPE_SYMLINK: u8 = 6;
230pub const RED_BRICK_FILE_TYPE_SOCKET: u8 = 7;
231pub const RED_BRICK_FILE_TYPE_PIPE: u8 = 8;
232pub const RED_BRICK_FILE_ORIGIN_BEGINNING: u8 = 0;
233pub const RED_BRICK_FILE_ORIGIN_CURRENT: u8 = 1;
234pub const RED_BRICK_FILE_ORIGIN_END: u8 = 2;
235pub const RED_BRICK_FILE_EVENT_READABLE: u16 = 1;
236pub const RED_BRICK_FILE_EVENT_WRITABLE: u16 = 2;
237pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_UNKNOWN: u8 = 0;
238pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_REGULAR: u8 = 1;
239pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_DIRECTORY: u8 = 2;
240pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_CHARACTER: u8 = 3;
241pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_BLOCK: u8 = 4;
242pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_FIFO: u8 = 5;
243pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_SYMLINK: u8 = 6;
244pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_SOCKET: u8 = 7;
245pub const RED_BRICK_DIRECTORY_FLAG_RECURSIVE: u32 = 1;
246pub const RED_BRICK_DIRECTORY_FLAG_EXCLUSIVE: u32 = 2;
247pub const RED_BRICK_PROCESS_SIGNAL_INTERRUPT: u8 = 2;
248pub const RED_BRICK_PROCESS_SIGNAL_QUIT: u8 = 3;
249pub const RED_BRICK_PROCESS_SIGNAL_ABORT: u8 = 6;
250pub const RED_BRICK_PROCESS_SIGNAL_KILL: u8 = 9;
251pub const RED_BRICK_PROCESS_SIGNAL_USER1: u8 = 10;
252pub const RED_BRICK_PROCESS_SIGNAL_USER2: u8 = 12;
253pub const RED_BRICK_PROCESS_SIGNAL_TERMINATE: u8 = 15;
254pub const RED_BRICK_PROCESS_SIGNAL_CONTINUE: u8 = 18;
255pub const RED_BRICK_PROCESS_SIGNAL_STOP: u8 = 19;
256pub const RED_BRICK_PROCESS_STATE_UNKNOWN: u8 = 0;
257pub const RED_BRICK_PROCESS_STATE_RUNNING: u8 = 1;
258pub const RED_BRICK_PROCESS_STATE_ERROR: u8 = 2;
259pub const RED_BRICK_PROCESS_STATE_EXITED: u8 = 3;
260pub const RED_BRICK_PROCESS_STATE_KILLED: u8 = 4;
261pub const RED_BRICK_PROCESS_STATE_STOPPED: u8 = 5;
262pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL: u8 = 0;
263pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE: u8 = 1;
264pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE: u8 = 2;
265pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG: u8 = 3;
266pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG: u8 = 4;
267pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT: u8 = 5;
268pub const RED_BRICK_PROGRAM_START_MODE_NEVER: u8 = 0;
269pub const RED_BRICK_PROGRAM_START_MODE_ALWAYS: u8 = 1;
270pub const RED_BRICK_PROGRAM_START_MODE_INTERVAL: u8 = 2;
271pub const RED_BRICK_PROGRAM_START_MODE_CRON: u8 = 3;
272pub const RED_BRICK_PROGRAM_SCHEDULER_STATE_STOPPED: u8 = 0;
273pub const RED_BRICK_PROGRAM_SCHEDULER_STATE_RUNNING: u8 = 1;
274
275#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
276pub struct CreateSession {
277 pub error_code: u8,
278 pub session_id: u16,
279}
280impl FromByteSlice for CreateSession {
281 fn bytes_expected() -> usize { 3 }
282 fn from_le_byte_slice(bytes: &[u8]) -> CreateSession {
283 CreateSession { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), session_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
284 }
285}
286
287#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
288pub struct AllocateString {
289 pub error_code: u8,
290 pub string_id: u16,
291}
292impl FromByteSlice for AllocateString {
293 fn bytes_expected() -> usize { 3 }
294 fn from_le_byte_slice(bytes: &[u8]) -> AllocateString {
295 AllocateString { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), string_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
296 }
297}
298
299#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
300pub struct StringLength {
301 pub error_code: u8,
302 pub length: u32,
303}
304impl FromByteSlice for StringLength {
305 fn bytes_expected() -> usize { 5 }
306 fn from_le_byte_slice(bytes: &[u8]) -> StringLength {
307 StringLength { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length: <u32>::from_le_byte_slice(&bytes[1..5]) }
308 }
309}
310
311#[derive(Clone)]
312pub struct StringChunk {
313 pub error_code: u8,
314 pub buffer: String,
315}
316impl FromByteSlice for StringChunk {
317 fn bytes_expected() -> usize { 64 }
318 fn from_le_byte_slice(bytes: &[u8]) -> StringChunk {
319 StringChunk { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), buffer: <String>::from_le_byte_slice(&bytes[1..64]) }
320 }
321}
322
323#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
324pub struct AllocateList {
325 pub error_code: u8,
326 pub list_id: u16,
327}
328impl FromByteSlice for AllocateList {
329 fn bytes_expected() -> usize { 3 }
330 fn from_le_byte_slice(bytes: &[u8]) -> AllocateList {
331 AllocateList { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
332 }
333}
334
335#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
336pub struct ListLength {
337 pub error_code: u8,
338 pub length: u16,
339}
340impl FromByteSlice for ListLength {
341 fn bytes_expected() -> usize { 3 }
342 fn from_le_byte_slice(bytes: &[u8]) -> ListLength {
343 ListLength { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length: <u16>::from_le_byte_slice(&bytes[1..3]) }
344 }
345}
346
347#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
348pub struct ListItem {
349 pub error_code: u8,
350 pub item_object_id: u16,
351 pub type_: u8,
352}
353impl FromByteSlice for ListItem {
354 fn bytes_expected() -> usize { 4 }
355 fn from_le_byte_slice(bytes: &[u8]) -> ListItem {
356 ListItem {
357 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
358 item_object_id: <u16>::from_le_byte_slice(&bytes[1..3]),
359 type_: <u8>::from_le_byte_slice(&bytes[3..4]),
360 }
361 }
362}
363
364#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
365pub struct OpenFile {
366 pub error_code: u8,
367 pub file_id: u16,
368}
369impl FromByteSlice for OpenFile {
370 fn bytes_expected() -> usize { 3 }
371 fn from_le_byte_slice(bytes: &[u8]) -> OpenFile {
372 OpenFile { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), file_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
373 }
374}
375
376#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
377pub struct CreatePipe {
378 pub error_code: u8,
379 pub file_id: u16,
380}
381impl FromByteSlice for CreatePipe {
382 fn bytes_expected() -> usize { 3 }
383 fn from_le_byte_slice(bytes: &[u8]) -> CreatePipe {
384 CreatePipe { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), file_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
385 }
386}
387
388#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
389pub struct FileInfo {
390 pub error_code: u8,
391 pub type_: u8,
392 pub name_string_id: u16,
393 pub flags: u32,
394 pub permissions: u16,
395 pub uid: u32,
396 pub gid: u32,
397 pub length: u64,
398 pub access_timestamp: u64,
399 pub modification_timestamp: u64,
400 pub status_change_timestamp: u64,
401}
402impl FromByteSlice for FileInfo {
403 fn bytes_expected() -> usize { 50 }
404 fn from_le_byte_slice(bytes: &[u8]) -> FileInfo {
405 FileInfo {
406 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
407 type_: <u8>::from_le_byte_slice(&bytes[1..2]),
408 name_string_id: <u16>::from_le_byte_slice(&bytes[2..4]),
409 flags: <u32>::from_le_byte_slice(&bytes[4..8]),
410 permissions: <u16>::from_le_byte_slice(&bytes[8..10]),
411 uid: <u32>::from_le_byte_slice(&bytes[10..14]),
412 gid: <u32>::from_le_byte_slice(&bytes[14..18]),
413 length: <u64>::from_le_byte_slice(&bytes[18..26]),
414 access_timestamp: <u64>::from_le_byte_slice(&bytes[26..34]),
415 modification_timestamp: <u64>::from_le_byte_slice(&bytes[34..42]),
416 status_change_timestamp: <u64>::from_le_byte_slice(&bytes[42..50]),
417 }
418 }
419}
420
421#[derive(Clone, Copy)]
422pub struct ReadFile {
423 pub error_code: u8,
424 pub buffer: [u8; 62],
425 pub length_read: u8,
426}
427impl FromByteSlice for ReadFile {
428 fn bytes_expected() -> usize { 64 }
429 fn from_le_byte_slice(bytes: &[u8]) -> ReadFile {
430 ReadFile {
431 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
432 buffer: <[u8; 62]>::from_le_byte_slice(&bytes[1..63]),
433 length_read: <u8>::from_le_byte_slice(&bytes[63..64]),
434 }
435 }
436}
437
438#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
439pub struct WriteFile {
440 pub error_code: u8,
441 pub length_written: u8,
442}
443impl FromByteSlice for WriteFile {
444 fn bytes_expected() -> usize { 2 }
445 fn from_le_byte_slice(bytes: &[u8]) -> WriteFile {
446 WriteFile { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length_written: <u8>::from_le_byte_slice(&bytes[1..2]) }
447 }
448}
449
450#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
451pub struct SetFilePosition {
452 pub error_code: u8,
453 pub position: u64,
454}
455impl FromByteSlice for SetFilePosition {
456 fn bytes_expected() -> usize { 9 }
457 fn from_le_byte_slice(bytes: &[u8]) -> SetFilePosition {
458 SetFilePosition { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), position: <u64>::from_le_byte_slice(&bytes[1..9]) }
459 }
460}
461
462#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
463pub struct FilePosition {
464 pub error_code: u8,
465 pub position: u64,
466}
467impl FromByteSlice for FilePosition {
468 fn bytes_expected() -> usize { 9 }
469 fn from_le_byte_slice(bytes: &[u8]) -> FilePosition {
470 FilePosition { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), position: <u64>::from_le_byte_slice(&bytes[1..9]) }
471 }
472}
473
474#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
475pub struct FileEvents {
476 pub error_code: u8,
477 pub events: u16,
478}
479impl FromByteSlice for FileEvents {
480 fn bytes_expected() -> usize { 3 }
481 fn from_le_byte_slice(bytes: &[u8]) -> FileEvents {
482 FileEvents { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), events: <u16>::from_le_byte_slice(&bytes[1..3]) }
483 }
484}
485
486#[derive(Clone, Copy)]
487pub struct AsyncFileReadEvent {
488 pub file_id: u16,
489 pub error_code: u8,
490 pub buffer: [u8; 60],
491 pub length_read: u8,
492}
493impl FromByteSlice for AsyncFileReadEvent {
494 fn bytes_expected() -> usize { 64 }
495 fn from_le_byte_slice(bytes: &[u8]) -> AsyncFileReadEvent {
496 AsyncFileReadEvent {
497 file_id: <u16>::from_le_byte_slice(&bytes[0..2]),
498 error_code: <u8>::from_le_byte_slice(&bytes[2..3]),
499 buffer: <[u8; 60]>::from_le_byte_slice(&bytes[3..63]),
500 length_read: <u8>::from_le_byte_slice(&bytes[63..64]),
501 }
502 }
503}
504
505#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
506pub struct AsyncFileWriteEvent {
507 pub file_id: u16,
508 pub error_code: u8,
509 pub length_written: u8,
510}
511impl FromByteSlice for AsyncFileWriteEvent {
512 fn bytes_expected() -> usize { 4 }
513 fn from_le_byte_slice(bytes: &[u8]) -> AsyncFileWriteEvent {
514 AsyncFileWriteEvent {
515 file_id: <u16>::from_le_byte_slice(&bytes[0..2]),
516 error_code: <u8>::from_le_byte_slice(&bytes[2..3]),
517 length_written: <u8>::from_le_byte_slice(&bytes[3..4]),
518 }
519 }
520}
521
522#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
523pub struct FileEventsOccurredEvent {
524 pub file_id: u16,
525 pub events: u16,
526}
527impl FromByteSlice for FileEventsOccurredEvent {
528 fn bytes_expected() -> usize { 4 }
529 fn from_le_byte_slice(bytes: &[u8]) -> FileEventsOccurredEvent {
530 FileEventsOccurredEvent { file_id: <u16>::from_le_byte_slice(&bytes[0..2]), events: <u16>::from_le_byte_slice(&bytes[2..4]) }
531 }
532}
533
534#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
535pub struct OpenDirectory {
536 pub error_code: u8,
537 pub directory_id: u16,
538}
539impl FromByteSlice for OpenDirectory {
540 fn bytes_expected() -> usize { 3 }
541 fn from_le_byte_slice(bytes: &[u8]) -> OpenDirectory {
542 OpenDirectory { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), directory_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
543 }
544}
545
546#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
547pub struct DirectoryName {
548 pub error_code: u8,
549 pub name_string_id: u16,
550}
551impl FromByteSlice for DirectoryName {
552 fn bytes_expected() -> usize { 3 }
553 fn from_le_byte_slice(bytes: &[u8]) -> DirectoryName {
554 DirectoryName { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), name_string_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
555 }
556}
557
558#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
559pub struct NextDirectoryEntry {
560 pub error_code: u8,
561 pub name_string_id: u16,
562 pub type_: u8,
563}
564impl FromByteSlice for NextDirectoryEntry {
565 fn bytes_expected() -> usize { 4 }
566 fn from_le_byte_slice(bytes: &[u8]) -> NextDirectoryEntry {
567 NextDirectoryEntry {
568 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
569 name_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
570 type_: <u8>::from_le_byte_slice(&bytes[3..4]),
571 }
572 }
573}
574
575#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
576pub struct Processes {
577 pub error_code: u8,
578 pub processes_list_id: u16,
579}
580impl FromByteSlice for Processes {
581 fn bytes_expected() -> usize { 3 }
582 fn from_le_byte_slice(bytes: &[u8]) -> Processes {
583 Processes { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), processes_list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
584 }
585}
586
587#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
588pub struct SpawnProcess {
589 pub error_code: u8,
590 pub process_id: u16,
591}
592impl FromByteSlice for SpawnProcess {
593 fn bytes_expected() -> usize { 3 }
594 fn from_le_byte_slice(bytes: &[u8]) -> SpawnProcess {
595 SpawnProcess { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), process_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
596 }
597}
598
599#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
600pub struct ProcessCommand {
601 pub error_code: u8,
602 pub executable_string_id: u16,
603 pub arguments_list_id: u16,
604 pub environment_list_id: u16,
605 pub working_directory_string_id: u16,
606}
607impl FromByteSlice for ProcessCommand {
608 fn bytes_expected() -> usize { 9 }
609 fn from_le_byte_slice(bytes: &[u8]) -> ProcessCommand {
610 ProcessCommand {
611 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
612 executable_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
613 arguments_list_id: <u16>::from_le_byte_slice(&bytes[3..5]),
614 environment_list_id: <u16>::from_le_byte_slice(&bytes[5..7]),
615 working_directory_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
616 }
617 }
618}
619
620#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
621pub struct ProcessIdentity {
622 pub error_code: u8,
623 pub pid: u32,
624 pub uid: u32,
625 pub gid: u32,
626}
627impl FromByteSlice for ProcessIdentity {
628 fn bytes_expected() -> usize { 13 }
629 fn from_le_byte_slice(bytes: &[u8]) -> ProcessIdentity {
630 ProcessIdentity {
631 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
632 pid: <u32>::from_le_byte_slice(&bytes[1..5]),
633 uid: <u32>::from_le_byte_slice(&bytes[5..9]),
634 gid: <u32>::from_le_byte_slice(&bytes[9..13]),
635 }
636 }
637}
638
639#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
640pub struct ProcessStdio {
641 pub error_code: u8,
642 pub stdin_file_id: u16,
643 pub stdout_file_id: u16,
644 pub stderr_file_id: u16,
645}
646impl FromByteSlice for ProcessStdio {
647 fn bytes_expected() -> usize { 7 }
648 fn from_le_byte_slice(bytes: &[u8]) -> ProcessStdio {
649 ProcessStdio {
650 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
651 stdin_file_id: <u16>::from_le_byte_slice(&bytes[1..3]),
652 stdout_file_id: <u16>::from_le_byte_slice(&bytes[3..5]),
653 stderr_file_id: <u16>::from_le_byte_slice(&bytes[5..7]),
654 }
655 }
656}
657
658#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
659pub struct ProcessState {
660 pub error_code: u8,
661 pub state: u8,
662 pub timestamp: u64,
663 pub exit_code: u8,
664}
665impl FromByteSlice for ProcessState {
666 fn bytes_expected() -> usize { 11 }
667 fn from_le_byte_slice(bytes: &[u8]) -> ProcessState {
668 ProcessState {
669 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
670 state: <u8>::from_le_byte_slice(&bytes[1..2]),
671 timestamp: <u64>::from_le_byte_slice(&bytes[2..10]),
672 exit_code: <u8>::from_le_byte_slice(&bytes[10..11]),
673 }
674 }
675}
676
677#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
678pub struct ProcessStateChangedEvent {
679 pub process_id: u16,
680 pub state: u8,
681 pub timestamp: u64,
682 pub exit_code: u8,
683}
684impl FromByteSlice for ProcessStateChangedEvent {
685 fn bytes_expected() -> usize { 12 }
686 fn from_le_byte_slice(bytes: &[u8]) -> ProcessStateChangedEvent {
687 ProcessStateChangedEvent {
688 process_id: <u16>::from_le_byte_slice(&bytes[0..2]),
689 state: <u8>::from_le_byte_slice(&bytes[2..3]),
690 timestamp: <u64>::from_le_byte_slice(&bytes[3..11]),
691 exit_code: <u8>::from_le_byte_slice(&bytes[11..12]),
692 }
693 }
694}
695
696#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
697pub struct Programs {
698 pub error_code: u8,
699 pub programs_list_id: u16,
700}
701impl FromByteSlice for Programs {
702 fn bytes_expected() -> usize { 3 }
703 fn from_le_byte_slice(bytes: &[u8]) -> Programs {
704 Programs { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), programs_list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
705 }
706}
707
708#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
709pub struct DefineProgram {
710 pub error_code: u8,
711 pub program_id: u16,
712}
713impl FromByteSlice for DefineProgram {
714 fn bytes_expected() -> usize { 3 }
715 fn from_le_byte_slice(bytes: &[u8]) -> DefineProgram {
716 DefineProgram { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), program_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
717 }
718}
719
720#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
721pub struct ProgramIdentifier {
722 pub error_code: u8,
723 pub identifier_string_id: u16,
724}
725impl FromByteSlice for ProgramIdentifier {
726 fn bytes_expected() -> usize { 3 }
727 fn from_le_byte_slice(bytes: &[u8]) -> ProgramIdentifier {
728 ProgramIdentifier {
729 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
730 identifier_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
731 }
732 }
733}
734
735#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
736pub struct ProgramRootDirectory {
737 pub error_code: u8,
738 pub root_directory_string_id: u16,
739}
740impl FromByteSlice for ProgramRootDirectory {
741 fn bytes_expected() -> usize { 3 }
742 fn from_le_byte_slice(bytes: &[u8]) -> ProgramRootDirectory {
743 ProgramRootDirectory {
744 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
745 root_directory_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
746 }
747 }
748}
749
750#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
751pub struct ProgramCommand {
752 pub error_code: u8,
753 pub executable_string_id: u16,
754 pub arguments_list_id: u16,
755 pub environment_list_id: u16,
756 pub working_directory_string_id: u16,
757}
758impl FromByteSlice for ProgramCommand {
759 fn bytes_expected() -> usize { 9 }
760 fn from_le_byte_slice(bytes: &[u8]) -> ProgramCommand {
761 ProgramCommand {
762 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
763 executable_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
764 arguments_list_id: <u16>::from_le_byte_slice(&bytes[3..5]),
765 environment_list_id: <u16>::from_le_byte_slice(&bytes[5..7]),
766 working_directory_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
767 }
768 }
769}
770
771#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
772pub struct ProgramStdioRedirection {
773 pub error_code: u8,
774 pub stdin_redirection: u8,
775 pub stdin_file_name_string_id: u16,
776 pub stdout_redirection: u8,
777 pub stdout_file_name_string_id: u16,
778 pub stderr_redirection: u8,
779 pub stderr_file_name_string_id: u16,
780}
781impl FromByteSlice for ProgramStdioRedirection {
782 fn bytes_expected() -> usize { 10 }
783 fn from_le_byte_slice(bytes: &[u8]) -> ProgramStdioRedirection {
784 ProgramStdioRedirection {
785 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
786 stdin_redirection: <u8>::from_le_byte_slice(&bytes[1..2]),
787 stdin_file_name_string_id: <u16>::from_le_byte_slice(&bytes[2..4]),
788 stdout_redirection: <u8>::from_le_byte_slice(&bytes[4..5]),
789 stdout_file_name_string_id: <u16>::from_le_byte_slice(&bytes[5..7]),
790 stderr_redirection: <u8>::from_le_byte_slice(&bytes[7..8]),
791 stderr_file_name_string_id: <u16>::from_le_byte_slice(&bytes[8..10]),
792 }
793 }
794}
795
796#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
797pub struct ProgramSchedule {
798 pub error_code: u8,
799 pub start_mode: u8,
800 pub continue_after_error: bool,
801 pub start_interval: u32,
802 pub start_fields_string_id: u16,
803}
804impl FromByteSlice for ProgramSchedule {
805 fn bytes_expected() -> usize { 9 }
806 fn from_le_byte_slice(bytes: &[u8]) -> ProgramSchedule {
807 ProgramSchedule {
808 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
809 start_mode: <u8>::from_le_byte_slice(&bytes[1..2]),
810 continue_after_error: <bool>::from_le_byte_slice(&bytes[2..3]),
811 start_interval: <u32>::from_le_byte_slice(&bytes[3..7]),
812 start_fields_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
813 }
814 }
815}
816
817#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
818pub struct ProgramSchedulerState {
819 pub error_code: u8,
820 pub state: u8,
821 pub timestamp: u64,
822 pub message_string_id: u16,
823}
824impl FromByteSlice for ProgramSchedulerState {
825 fn bytes_expected() -> usize { 12 }
826 fn from_le_byte_slice(bytes: &[u8]) -> ProgramSchedulerState {
827 ProgramSchedulerState {
828 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
829 state: <u8>::from_le_byte_slice(&bytes[1..2]),
830 timestamp: <u64>::from_le_byte_slice(&bytes[2..10]),
831 message_string_id: <u16>::from_le_byte_slice(&bytes[10..12]),
832 }
833 }
834}
835
836#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
837pub struct LastSpawnedProgramProcess {
838 pub error_code: u8,
839 pub process_id: u16,
840 pub timestamp: u64,
841}
842impl FromByteSlice for LastSpawnedProgramProcess {
843 fn bytes_expected() -> usize { 11 }
844 fn from_le_byte_slice(bytes: &[u8]) -> LastSpawnedProgramProcess {
845 LastSpawnedProgramProcess {
846 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
847 process_id: <u16>::from_le_byte_slice(&bytes[1..3]),
848 timestamp: <u64>::from_le_byte_slice(&bytes[3..11]),
849 }
850 }
851}
852
853#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
854pub struct CustomProgramOptionNames {
855 pub error_code: u8,
856 pub names_list_id: u16,
857}
858impl FromByteSlice for CustomProgramOptionNames {
859 fn bytes_expected() -> usize { 3 }
860 fn from_le_byte_slice(bytes: &[u8]) -> CustomProgramOptionNames {
861 CustomProgramOptionNames {
862 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
863 names_list_id: <u16>::from_le_byte_slice(&bytes[1..3]),
864 }
865 }
866}
867
868#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
869pub struct CustomProgramOptionValue {
870 pub error_code: u8,
871 pub value_string_id: u16,
872}
873impl FromByteSlice for CustomProgramOptionValue {
874 fn bytes_expected() -> usize { 3 }
875 fn from_le_byte_slice(bytes: &[u8]) -> CustomProgramOptionValue {
876 CustomProgramOptionValue {
877 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
878 value_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
879 }
880 }
881}
882
883#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
884pub struct Identity {
885 pub uid: String,
886 pub connected_uid: String,
887 pub position: char,
888 pub hardware_version: [u8; 3],
889 pub firmware_version: [u8; 3],
890 pub device_identifier: u16,
891}
892impl FromByteSlice for Identity {
893 fn bytes_expected() -> usize { 25 }
894 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
895 Identity {
896 uid: <String>::from_le_byte_slice(&bytes[0..8]),
897 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
898 position: <char>::from_le_byte_slice(&bytes[16..17]),
899 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
900 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
901 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
902 }
903 }
904}
905
906/// Executes user programs and controls other Bricks/Bricklets standalone
907#[derive(Clone)]
908pub struct RedBrick {
909 device: Device,
910}
911impl RedBrick {
912 pub const DEVICE_IDENTIFIER: u16 = 17;
913 pub const DEVICE_DISPLAY_NAME: &'static str = "RED Brick";
914 /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
915 pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> RedBrick {
916 let mut result = RedBrick { device: Device::new([2, 0, 0], uid, req_sender, 0) };
917 result.device.response_expected[u8::from(RedBrickFunction::CreateSession) as usize] = ResponseExpectedFlag::AlwaysTrue;
918 result.device.response_expected[u8::from(RedBrickFunction::ExpireSession) as usize] = ResponseExpectedFlag::AlwaysTrue;
919 result.device.response_expected[u8::from(RedBrickFunction::ExpireSessionUnchecked) as usize] = ResponseExpectedFlag::False;
920 result.device.response_expected[u8::from(RedBrickFunction::KeepSessionAlive) as usize] = ResponseExpectedFlag::AlwaysTrue;
921 result.device.response_expected[u8::from(RedBrickFunction::ReleaseObject) as usize] = ResponseExpectedFlag::AlwaysTrue;
922 result.device.response_expected[u8::from(RedBrickFunction::ReleaseObjectUnchecked) as usize] = ResponseExpectedFlag::False;
923 result.device.response_expected[u8::from(RedBrickFunction::AllocateString) as usize] = ResponseExpectedFlag::AlwaysTrue;
924 result.device.response_expected[u8::from(RedBrickFunction::TruncateString) as usize] = ResponseExpectedFlag::AlwaysTrue;
925 result.device.response_expected[u8::from(RedBrickFunction::GetStringLength) as usize] = ResponseExpectedFlag::AlwaysTrue;
926 result.device.response_expected[u8::from(RedBrickFunction::SetStringChunk) as usize] = ResponseExpectedFlag::AlwaysTrue;
927 result.device.response_expected[u8::from(RedBrickFunction::GetStringChunk) as usize] = ResponseExpectedFlag::AlwaysTrue;
928 result.device.response_expected[u8::from(RedBrickFunction::AllocateList) as usize] = ResponseExpectedFlag::AlwaysTrue;
929 result.device.response_expected[u8::from(RedBrickFunction::GetListLength) as usize] = ResponseExpectedFlag::AlwaysTrue;
930 result.device.response_expected[u8::from(RedBrickFunction::GetListItem) as usize] = ResponseExpectedFlag::AlwaysTrue;
931 result.device.response_expected[u8::from(RedBrickFunction::AppendToList) as usize] = ResponseExpectedFlag::AlwaysTrue;
932 result.device.response_expected[u8::from(RedBrickFunction::RemoveFromList) as usize] = ResponseExpectedFlag::AlwaysTrue;
933 result.device.response_expected[u8::from(RedBrickFunction::OpenFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
934 result.device.response_expected[u8::from(RedBrickFunction::CreatePipe) as usize] = ResponseExpectedFlag::AlwaysTrue;
935 result.device.response_expected[u8::from(RedBrickFunction::GetFileInfo) as usize] = ResponseExpectedFlag::AlwaysTrue;
936 result.device.response_expected[u8::from(RedBrickFunction::ReadFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
937 result.device.response_expected[u8::from(RedBrickFunction::ReadFileAsync) as usize] = ResponseExpectedFlag::False;
938 result.device.response_expected[u8::from(RedBrickFunction::AbortAsyncFileRead) as usize] = ResponseExpectedFlag::AlwaysTrue;
939 result.device.response_expected[u8::from(RedBrickFunction::WriteFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
940 result.device.response_expected[u8::from(RedBrickFunction::WriteFileUnchecked) as usize] = ResponseExpectedFlag::False;
941 result.device.response_expected[u8::from(RedBrickFunction::WriteFileAsync) as usize] = ResponseExpectedFlag::False;
942 result.device.response_expected[u8::from(RedBrickFunction::SetFilePosition) as usize] = ResponseExpectedFlag::AlwaysTrue;
943 result.device.response_expected[u8::from(RedBrickFunction::GetFilePosition) as usize] = ResponseExpectedFlag::AlwaysTrue;
944 result.device.response_expected[u8::from(RedBrickFunction::SetFileEvents) as usize] = ResponseExpectedFlag::AlwaysTrue;
945 result.device.response_expected[u8::from(RedBrickFunction::GetFileEvents) as usize] = ResponseExpectedFlag::AlwaysTrue;
946 result.device.response_expected[u8::from(RedBrickFunction::OpenDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
947 result.device.response_expected[u8::from(RedBrickFunction::GetDirectoryName) as usize] = ResponseExpectedFlag::AlwaysTrue;
948 result.device.response_expected[u8::from(RedBrickFunction::GetNextDirectoryEntry) as usize] = ResponseExpectedFlag::AlwaysTrue;
949 result.device.response_expected[u8::from(RedBrickFunction::RewindDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
950 result.device.response_expected[u8::from(RedBrickFunction::CreateDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
951 result.device.response_expected[u8::from(RedBrickFunction::GetProcesses) as usize] = ResponseExpectedFlag::AlwaysTrue;
952 result.device.response_expected[u8::from(RedBrickFunction::SpawnProcess) as usize] = ResponseExpectedFlag::AlwaysTrue;
953 result.device.response_expected[u8::from(RedBrickFunction::KillProcess) as usize] = ResponseExpectedFlag::AlwaysTrue;
954 result.device.response_expected[u8::from(RedBrickFunction::GetProcessCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
955 result.device.response_expected[u8::from(RedBrickFunction::GetProcessIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
956 result.device.response_expected[u8::from(RedBrickFunction::GetProcessStdio) as usize] = ResponseExpectedFlag::AlwaysTrue;
957 result.device.response_expected[u8::from(RedBrickFunction::GetProcessState) as usize] = ResponseExpectedFlag::AlwaysTrue;
958 result.device.response_expected[u8::from(RedBrickFunction::GetPrograms) as usize] = ResponseExpectedFlag::AlwaysTrue;
959 result.device.response_expected[u8::from(RedBrickFunction::DefineProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
960 result.device.response_expected[u8::from(RedBrickFunction::PurgeProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
961 result.device.response_expected[u8::from(RedBrickFunction::GetProgramIdentifier) as usize] = ResponseExpectedFlag::AlwaysTrue;
962 result.device.response_expected[u8::from(RedBrickFunction::GetProgramRootDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
963 result.device.response_expected[u8::from(RedBrickFunction::SetProgramCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
964 result.device.response_expected[u8::from(RedBrickFunction::GetProgramCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
965 result.device.response_expected[u8::from(RedBrickFunction::SetProgramStdioRedirection) as usize] = ResponseExpectedFlag::AlwaysTrue;
966 result.device.response_expected[u8::from(RedBrickFunction::GetProgramStdioRedirection) as usize] = ResponseExpectedFlag::AlwaysTrue;
967 result.device.response_expected[u8::from(RedBrickFunction::SetProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
968 result.device.response_expected[u8::from(RedBrickFunction::GetProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
969 result.device.response_expected[u8::from(RedBrickFunction::GetProgramSchedulerState) as usize] = ResponseExpectedFlag::AlwaysTrue;
970 result.device.response_expected[u8::from(RedBrickFunction::ContinueProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
971 result.device.response_expected[u8::from(RedBrickFunction::StartProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
972 result.device.response_expected[u8::from(RedBrickFunction::GetLastSpawnedProgramProcess) as usize] =
973 ResponseExpectedFlag::AlwaysTrue;
974 result.device.response_expected[u8::from(RedBrickFunction::GetCustomProgramOptionNames) as usize] =
975 ResponseExpectedFlag::AlwaysTrue;
976 result.device.response_expected[u8::from(RedBrickFunction::SetCustomProgramOptionValue) as usize] =
977 ResponseExpectedFlag::AlwaysTrue;
978 result.device.response_expected[u8::from(RedBrickFunction::GetCustomProgramOptionValue) as usize] =
979 ResponseExpectedFlag::AlwaysTrue;
980 result.device.response_expected[u8::from(RedBrickFunction::RemoveCustomProgramOption) as usize] = ResponseExpectedFlag::AlwaysTrue;
981 result.device.response_expected[u8::from(RedBrickFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
982 result
983 }
984
985 /// Returns the response expected flag for the function specified by the function ID parameter.
986 /// It is true if the function is expected to send a response, false otherwise.
987 ///
988 /// For getter functions this is enabled by default and cannot be disabled, because those
989 /// functions will always send a response. For callback configuration functions it is enabled
990 /// by default too, but can be disabled by [`set_response_expected`](crate::red_brick::RedBrick::set_response_expected).
991 /// For setter functions it is disabled by default and can be enabled.
992 ///
993 /// Enabling the response expected flag for a setter function allows to detect timeouts
994 /// and other error conditions calls of this setter as well. The device will then send a response
995 /// for this purpose. If this flag is disabled for a setter function then no response is sent
996 /// and errors are silently ignored, because they cannot be detected.
997 ///
998 /// See [`set_response_expected`](crate::red_brick::RedBrick::set_response_expected) for the list of function ID constants available for this function.
999 pub fn get_response_expected(&mut self, fun: RedBrickFunction) -> Result<bool, GetResponseExpectedError> {
1000 self.device.get_response_expected(u8::from(fun))
1001 }
1002
1003 /// Changes the response expected flag of the function specified by the function ID parameter.
1004 /// This flag can only be changed for setter (default value: false) and callback configuration
1005 /// functions (default value: true). For getter functions it is always enabled.
1006 ///
1007 /// Enabling the response expected flag for a setter function allows to detect timeouts and
1008 /// other error conditions calls of this setter as well. The device will then send a response
1009 /// for this purpose. If this flag is disabled for a setter function then no response is sent
1010 /// and errors are silently ignored, because they cannot be detected.
1011 pub fn set_response_expected(&mut self, fun: RedBrickFunction, response_expected: bool) -> Result<(), SetResponseExpectedError> {
1012 self.device.set_response_expected(u8::from(fun), response_expected)
1013 }
1014
1015 /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
1016 pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
1017
1018 /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
1019 /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
1020 pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
1021
1022 /// This receiver reports the result of a call to the [`read_file_async`]
1023 /// function.
1024 ///
1025 /// [`read_file_async`]: #method.read_file_async
1026 pub fn get_async_file_read_callback_receiver(&self) -> ConvertingCallbackReceiver<AsyncFileReadEvent> {
1027 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackAsyncFileRead))
1028 }
1029
1030 /// This receiver reports the result of a call to the [`write_file_async`]
1031 /// function.
1032 pub fn get_async_file_write_callback_receiver(&self) -> ConvertingCallbackReceiver<AsyncFileWriteEvent> {
1033 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackAsyncFileWrite))
1034 }
1035
1036 ///
1037 pub fn get_file_events_occurred_callback_receiver(&self) -> ConvertingCallbackReceiver<FileEventsOccurredEvent> {
1038 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackFileEventsOccurred))
1039 }
1040
1041 ///
1042 pub fn get_process_state_changed_callback_receiver(&self) -> ConvertingCallbackReceiver<ProcessStateChangedEvent> {
1043 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackProcessStateChanged))
1044 }
1045
1046 ///
1047 pub fn get_program_scheduler_state_changed_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
1048 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackProgramSchedulerStateChanged))
1049 }
1050
1051 ///
1052 pub fn get_program_process_spawned_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
1053 self.device.get_callback_receiver(u8::from(RedBrickFunction::CallbackProgramProcessSpawned))
1054 }
1055
1056 ///
1057 ///
1058 /// Associated constants:
1059 /// * RED_BRICK_ERROR_CODE_SUCCESS
1060 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1061 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1062 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1063 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1064 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1065 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1066 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1067 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1068 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1069 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1070 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1071 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1072 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1073 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1074 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1075 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1076 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1077 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1078 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1079 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1080 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1081 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1082 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1083 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1084 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1085 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1086 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1087 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1088 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1089 pub fn create_session(&self, lifetime: u32) -> ConvertingReceiver<CreateSession> {
1090 let mut payload = vec![0; 4];
1091 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(lifetime));
1092
1093 self.device.get(u8::from(RedBrickFunction::CreateSession), payload)
1094 }
1095
1096 ///
1097 ///
1098 /// Associated constants:
1099 /// * RED_BRICK_ERROR_CODE_SUCCESS
1100 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1101 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1102 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1103 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1104 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1105 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1106 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1107 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1108 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1109 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1110 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1111 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1112 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1113 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1114 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1115 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1116 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1117 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1118 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1119 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1120 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1121 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1122 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1123 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1124 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1125 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1126 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1127 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1128 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1129 pub fn expire_session(&self, session_id: u16) -> ConvertingReceiver<u8> {
1130 let mut payload = vec![0; 2];
1131 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1132
1133 self.device.get(u8::from(RedBrickFunction::ExpireSession), payload)
1134 }
1135
1136 ///
1137 pub fn expire_session_unchecked(&self, session_id: u16) -> ConvertingReceiver<()> {
1138 let mut payload = vec![0; 2];
1139 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1140
1141 self.device.set(u8::from(RedBrickFunction::ExpireSessionUnchecked), payload)
1142 }
1143
1144 ///
1145 ///
1146 /// Associated constants:
1147 /// * RED_BRICK_ERROR_CODE_SUCCESS
1148 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1149 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1150 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1151 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1152 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1153 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1154 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1155 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1156 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1157 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1158 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1159 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1160 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1161 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1162 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1163 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1164 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1165 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1166 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1167 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1168 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1169 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1170 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1171 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1172 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1173 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1174 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1175 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1176 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1177 pub fn keep_session_alive(&self, session_id: u16, lifetime: u32) -> ConvertingReceiver<u8> {
1178 let mut payload = vec![0; 6];
1179 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1180 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(lifetime));
1181
1182 self.device.get(u8::from(RedBrickFunction::KeepSessionAlive), payload)
1183 }
1184
1185 /// Decreases the reference count of an object by one and returns the resulting
1186 /// error code. If the reference count reaches zero the object gets destroyed.
1187 ///
1188 /// Associated constants:
1189 /// * RED_BRICK_ERROR_CODE_SUCCESS
1190 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1191 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1192 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1193 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1194 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1195 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1196 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1197 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1198 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1199 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1200 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1201 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1202 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1203 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1204 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1205 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1206 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1207 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1208 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1209 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1210 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1211 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1212 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1213 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1214 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1215 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1216 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1217 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1218 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1219 pub fn release_object(&self, object_id: u16, session_id: u16) -> ConvertingReceiver<u8> {
1220 let mut payload = vec![0; 4];
1221 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(object_id));
1222 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1223
1224 self.device.get(u8::from(RedBrickFunction::ReleaseObject), payload)
1225 }
1226
1227 ///
1228 pub fn release_object_unchecked(&self, object_id: u16, session_id: u16) -> ConvertingReceiver<()> {
1229 let mut payload = vec![0; 4];
1230 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(object_id));
1231 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1232
1233 self.device.set(u8::from(RedBrickFunction::ReleaseObjectUnchecked), payload)
1234 }
1235
1236 /// Allocates a new string object, reserves ``length_to_reserve`` bytes memory
1237 /// for it and sets up to the first 60 bytes. Set ``length_to_reserve`` to the
1238 /// length of the string that should be stored in the string object.
1239 ///
1240 /// Returns the object ID of the new string object and the resulting error code.
1241 ///
1242 /// Associated constants:
1243 /// * RED_BRICK_ERROR_CODE_SUCCESS
1244 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1245 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1246 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1247 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1248 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1249 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1250 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1251 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1252 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1253 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1254 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1255 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1256 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1257 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1258 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1259 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1260 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1261 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1262 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1263 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1264 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1265 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1266 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1267 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1268 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1269 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1270 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1271 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1272 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1273 pub fn allocate_string(&self, length_to_reserve: u32, buffer: String, session_id: u16) -> ConvertingReceiver<AllocateString> {
1274 let mut payload = vec![0; 64];
1275 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(length_to_reserve));
1276 match <String>::try_to_le_byte_vec(buffer, 58) {
1277 Err(e) => {
1278 let (tx, rx) = std::sync::mpsc::channel::<Result<Vec<u8>, BrickletError>>();
1279 let _ = tx.send(Err(e));
1280 return ConvertingReceiver::new(rx, std::time::Duration::new(1, 0));
1281 }
1282 Ok(bytes) => payload[4..62].copy_from_slice(&bytes),
1283 }
1284
1285 payload[62..64].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1286
1287 self.device.get(u8::from(RedBrickFunction::AllocateString), payload)
1288 }
1289
1290 /// Truncates a string object to ``length`` bytes and returns the resulting
1291 /// error code.
1292 ///
1293 /// Associated constants:
1294 /// * RED_BRICK_ERROR_CODE_SUCCESS
1295 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1296 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1297 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1298 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1299 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1300 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1301 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1302 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1303 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1304 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1305 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1306 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1307 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1308 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1309 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1310 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1311 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1312 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1313 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1314 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1315 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1316 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1317 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1318 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1319 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1320 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1321 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1322 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1323 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1324 pub fn truncate_string(&self, string_id: u16, length: u32) -> ConvertingReceiver<u8> {
1325 let mut payload = vec![0; 6];
1326 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(string_id));
1327 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(length));
1328
1329 self.device.get(u8::from(RedBrickFunction::TruncateString), payload)
1330 }
1331
1332 /// Returns the length of a string object and the resulting error code.
1333 ///
1334 /// Associated constants:
1335 /// * RED_BRICK_ERROR_CODE_SUCCESS
1336 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1337 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1338 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1339 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1340 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1341 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1342 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1343 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1344 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1345 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1346 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1347 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1348 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1349 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1350 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1351 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1352 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1353 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1354 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1355 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1356 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1357 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1358 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1359 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1360 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1361 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1362 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1363 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1364 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1365 pub fn get_string_length(&self, string_id: u16) -> ConvertingReceiver<StringLength> {
1366 let mut payload = vec![0; 2];
1367 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(string_id));
1368
1369 self.device.get(u8::from(RedBrickFunction::GetStringLength), payload)
1370 }
1371
1372 /// Sets a chunk of up to 58 bytes in a string object beginning at ``offset``.
1373 ///
1374 /// Returns the resulting error code.
1375 ///
1376 /// Associated constants:
1377 /// * RED_BRICK_ERROR_CODE_SUCCESS
1378 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1379 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1380 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1381 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1382 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1383 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1384 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1385 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1386 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1387 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1388 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1389 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1390 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1391 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1392 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1393 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1394 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1395 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1396 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1397 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1398 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1399 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1400 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1401 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1402 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1403 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1404 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1405 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1406 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1407 pub fn set_string_chunk(&self, string_id: u16, offset: u32, buffer: String) -> ConvertingReceiver<u8> {
1408 let mut payload = vec![0; 64];
1409 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(string_id));
1410 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(offset));
1411 match <String>::try_to_le_byte_vec(buffer, 58) {
1412 Err(e) => {
1413 let (tx, rx) = std::sync::mpsc::channel::<Result<Vec<u8>, BrickletError>>();
1414 let _ = tx.send(Err(e));
1415 return ConvertingReceiver::new(rx, std::time::Duration::new(1, 0));
1416 }
1417 Ok(bytes) => payload[6..64].copy_from_slice(&bytes),
1418 }
1419
1420 self.device.get(u8::from(RedBrickFunction::SetStringChunk), payload)
1421 }
1422
1423 /// Returns a chunk up to 63 bytes from a string object beginning at ``offset`` and
1424 /// returns the resulting error code.
1425 ///
1426 /// Associated constants:
1427 /// * RED_BRICK_ERROR_CODE_SUCCESS
1428 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1429 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1430 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1431 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1432 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1433 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1434 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1435 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1436 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1437 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1438 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1439 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1440 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1441 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1442 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1443 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1444 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1445 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1446 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1447 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1448 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1449 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1450 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1451 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1452 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1453 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1454 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1455 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1456 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1457 pub fn get_string_chunk(&self, string_id: u16, offset: u32) -> ConvertingReceiver<StringChunk> {
1458 let mut payload = vec![0; 6];
1459 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(string_id));
1460 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(offset));
1461
1462 self.device.get(u8::from(RedBrickFunction::GetStringChunk), payload)
1463 }
1464
1465 /// Allocates a new list object and reserves memory for ``length_to_reserve``
1466 /// items. Set ``length_to_reserve`` to the number of items that should be stored
1467 /// in the list object.
1468 ///
1469 /// Returns the object ID of the new list object and the resulting error code.
1470 ///
1471 /// When a list object gets destroyed then the reference count of each object in
1472 /// the list object is decreased by one.
1473 ///
1474 /// Associated constants:
1475 /// * RED_BRICK_ERROR_CODE_SUCCESS
1476 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1477 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1478 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1479 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1480 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1481 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1482 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1483 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1484 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1485 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1486 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1487 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1488 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1489 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1490 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1491 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1492 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1493 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1494 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1495 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1496 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1497 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1498 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1499 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1500 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1501 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1502 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1503 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1504 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1505 pub fn allocate_list(&self, length_to_reserve: u16, session_id: u16) -> ConvertingReceiver<AllocateList> {
1506 let mut payload = vec![0; 4];
1507 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(length_to_reserve));
1508 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1509
1510 self.device.get(u8::from(RedBrickFunction::AllocateList), payload)
1511 }
1512
1513 /// Returns the length of a list object in items and the resulting error code.
1514 ///
1515 /// Associated constants:
1516 /// * RED_BRICK_ERROR_CODE_SUCCESS
1517 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1518 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1519 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1520 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1521 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1522 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1523 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1524 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1525 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1526 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1527 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1528 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1529 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1530 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1531 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1532 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1533 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1534 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1535 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1536 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1537 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1538 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1539 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1540 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1541 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1542 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1543 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1544 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1545 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1546 pub fn get_list_length(&self, list_id: u16) -> ConvertingReceiver<ListLength> {
1547 let mut payload = vec![0; 2];
1548 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(list_id));
1549
1550 self.device.get(u8::from(RedBrickFunction::GetListLength), payload)
1551 }
1552
1553 /// Returns the object ID and type of the object stored at ``index`` in a list
1554 /// object and returns the resulting error code.
1555 ///
1556 /// Possible object types are:
1557 ///
1558 /// * String = 0
1559 /// * List = 1
1560 /// * File = 2
1561 /// * Directory = 3
1562 /// * Process = 4
1563 /// * Program = 5
1564 ///
1565 /// Associated constants:
1566 /// * RED_BRICK_ERROR_CODE_SUCCESS
1567 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1568 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1569 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1570 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1571 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1572 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1573 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1574 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1575 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1576 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1577 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1578 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1579 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1580 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1581 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1582 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1583 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1584 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1585 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1586 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1587 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1588 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1589 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1590 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1591 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1592 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1593 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1594 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1595 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1596 /// * RED_BRICK_OBJECT_TYPE_STRING
1597 /// * RED_BRICK_OBJECT_TYPE_LIST
1598 /// * RED_BRICK_OBJECT_TYPE_FILE
1599 /// * RED_BRICK_OBJECT_TYPE_DIRECTORY
1600 /// * RED_BRICK_OBJECT_TYPE_PROCESS
1601 /// * RED_BRICK_OBJECT_TYPE_PROGRAM
1602 pub fn get_list_item(&self, list_id: u16, index: u16, session_id: u16) -> ConvertingReceiver<ListItem> {
1603 let mut payload = vec![0; 6];
1604 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(list_id));
1605 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(index));
1606 payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1607
1608 self.device.get(u8::from(RedBrickFunction::GetListItem), payload)
1609 }
1610
1611 /// Appends an object to a list object and increases the reference count of the
1612 /// appended object by one.
1613 ///
1614 /// Returns the resulting error code.
1615 ///
1616 /// Associated constants:
1617 /// * RED_BRICK_ERROR_CODE_SUCCESS
1618 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1619 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1620 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1621 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1622 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1623 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1624 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1625 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1626 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1627 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1628 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1629 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1630 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1631 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1632 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1633 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1634 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1635 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1636 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1637 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1638 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1639 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1640 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1641 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1642 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1643 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1644 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1645 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1646 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1647 pub fn append_to_list(&self, list_id: u16, item_object_id: u16) -> ConvertingReceiver<u8> {
1648 let mut payload = vec![0; 4];
1649 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(list_id));
1650 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(item_object_id));
1651
1652 self.device.get(u8::from(RedBrickFunction::AppendToList), payload)
1653 }
1654
1655 /// Removes the object stored at ``index`` from a list object and decreases the
1656 /// reference count of the removed object by one.
1657 ///
1658 /// Returns the resulting error code.
1659 ///
1660 /// Associated constants:
1661 /// * RED_BRICK_ERROR_CODE_SUCCESS
1662 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1663 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1664 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1665 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1666 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1667 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1668 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1669 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1670 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1671 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1672 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1673 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1674 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1675 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1676 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1677 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1678 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1679 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1680 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1681 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1682 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1683 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1684 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1685 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1686 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1687 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1688 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1689 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1690 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1691 pub fn remove_from_list(&self, list_id: u16, index: u16) -> ConvertingReceiver<u8> {
1692 let mut payload = vec![0; 4];
1693 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(list_id));
1694 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(index));
1695
1696 self.device.get(u8::from(RedBrickFunction::RemoveFromList), payload)
1697 }
1698
1699 /// Opens an existing file or creates a new file and allocates a new file object
1700 /// for it.
1701 ///
1702 /// FIXME: name has to be absolute
1703 ///
1704 /// The reference count of the name string object is increased by one. When the
1705 /// file object gets destroyed then the reference count of the name string object is
1706 /// decreased by one. Also the name string object is locked and cannot be modified
1707 /// while the file object holds a reference to it.
1708 ///
1709 /// The ``flags`` parameter takes a ORed combination of the following possible file
1710 /// flags (in hexadecimal notation):
1711 ///
1712 /// * ReadOnly = 0x0001 (O_RDONLY)
1713 /// * WriteOnly = 0x0002 (O_WRONLY)
1714 /// * ReadWrite = 0x0004 (O_RDWR)
1715 /// * Append = 0x0008 (O_APPEND)
1716 /// * Create = 0x0010 (O_CREAT)
1717 /// * Exclusive = 0x0020 (O_EXCL)
1718 /// * NonBlocking = 0x0040 (O_NONBLOCK)
1719 /// * Truncate = 0x0080 (O_TRUNC)
1720 /// * Temporary = 0x0100
1721 /// * Replace = 0x0200
1722 ///
1723 /// FIXME: explain *Temporary* and *Replace* flag
1724 ///
1725 /// The ``permissions`` parameter takes a ORed combination of the following
1726 /// possible file permissions (in octal notation) that match the common UNIX
1727 /// permission bits:
1728 ///
1729 /// * UserRead = 00400
1730 /// * UserWrite = 00200
1731 /// * UserExecute = 00100
1732 /// * GroupRead = 00040
1733 /// * GroupWrite = 00020
1734 /// * GroupExecute = 00010
1735 /// * OthersRead = 00004
1736 /// * OthersWrite = 00002
1737 /// * OthersExecute = 00001
1738 ///
1739 /// Returns the object ID of the new file object and the resulting error code.
1740 ///
1741 /// Associated constants:
1742 /// * RED_BRICK_FILE_FLAG_READ_ONLY
1743 /// * RED_BRICK_FILE_FLAG_WRITE_ONLY
1744 /// * RED_BRICK_FILE_FLAG_READ_WRITE
1745 /// * RED_BRICK_FILE_FLAG_APPEND
1746 /// * RED_BRICK_FILE_FLAG_CREATE
1747 /// * RED_BRICK_FILE_FLAG_EXCLUSIVE
1748 /// * RED_BRICK_FILE_FLAG_NON_BLOCKING
1749 /// * RED_BRICK_FILE_FLAG_TRUNCATE
1750 /// * RED_BRICK_FILE_FLAG_TEMPORARY
1751 /// * RED_BRICK_FILE_FLAG_REPLACE
1752 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
1753 /// * RED_BRICK_FILE_PERMISSION_USER_READ
1754 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
1755 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
1756 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
1757 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
1758 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
1759 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
1760 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
1761 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
1762 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
1763 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
1764 /// * RED_BRICK_ERROR_CODE_SUCCESS
1765 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1766 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1767 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1768 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1769 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1770 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1771 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1772 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1773 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1774 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1775 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1776 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1777 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1778 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1779 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1780 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1781 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1782 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1783 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1784 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1785 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1786 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1787 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1788 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1789 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1790 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1791 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1792 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1793 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1794 pub fn open_file(
1795 &self,
1796 name_string_id: u16,
1797 flags: u32,
1798 permissions: u16,
1799 uid: u32,
1800 gid: u32,
1801 session_id: u16,
1802 ) -> ConvertingReceiver<OpenFile> {
1803 let mut payload = vec![0; 18];
1804 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
1805 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(flags));
1806 payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(permissions));
1807 payload[8..12].copy_from_slice(&<u32>::to_le_byte_vec(uid));
1808 payload[12..16].copy_from_slice(&<u32>::to_le_byte_vec(gid));
1809 payload[16..18].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1810
1811 self.device.get(u8::from(RedBrickFunction::OpenFile), payload)
1812 }
1813
1814 /// Creates a new pipe and allocates a new file object for it.
1815 ///
1816 /// The ``flags`` parameter takes a ORed combination of the following possible
1817 /// pipe flags (in hexadecimal notation):
1818 ///
1819 /// * NonBlockingRead = 0x0001
1820 /// * NonBlockingWrite = 0x0002
1821 ///
1822 /// The length of the pipe buffer can be specified with the ``length`` parameter
1823 /// in bytes. If length is set to zero, then the default pipe buffer length is used.
1824 ///
1825 /// Returns the object ID of the new file object and the resulting error code.
1826 ///
1827 /// Associated constants:
1828 /// * RED_BRICK_PIPE_FLAG_NON_BLOCKING_READ
1829 /// * RED_BRICK_PIPE_FLAG_NON_BLOCKING_WRITE
1830 /// * RED_BRICK_ERROR_CODE_SUCCESS
1831 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1832 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1833 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1834 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1835 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1836 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1837 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1838 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1839 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1840 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1841 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1842 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1843 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1844 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1845 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1846 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1847 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1848 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1849 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1850 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1851 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1852 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1853 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1854 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1855 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1856 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1857 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1858 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1859 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1860 pub fn create_pipe(&self, flags: u32, length: u64, session_id: u16) -> ConvertingReceiver<CreatePipe> {
1861 let mut payload = vec![0; 14];
1862 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(flags));
1863 payload[4..12].copy_from_slice(&<u64>::to_le_byte_vec(length));
1864 payload[12..14].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1865
1866 self.device.get(u8::from(RedBrickFunction::CreatePipe), payload)
1867 }
1868
1869 /// Returns various information about a file and the resulting error code.
1870 ///
1871 /// Possible file types are:
1872 ///
1873 /// * Unknown = 0
1874 /// * Regular = 1
1875 /// * Directory = 2
1876 /// * Character = 3
1877 /// * Block = 4
1878 /// * FIFO = 5
1879 /// * Symlink = 6
1880 /// * Socket = 7
1881 /// * Pipe = 8
1882 ///
1883 /// If the file type is *Pipe* then the returned name string object is invalid,
1884 /// because a pipe has no name. Otherwise the returned name string object was used
1885 /// to open or create the file object, as passed to [`open_file`].
1886 ///
1887 /// The returned flags were used to open or create the file object, as passed to
1888 /// [`open_file`] or [`create_pipe`]. See the respective function for a list
1889 /// of possible file and pipe flags.
1890 ///
1891 /// FIXME: everything except flags and length is invalid if file type is *Pipe*
1892 ///
1893 /// Associated constants:
1894 /// * RED_BRICK_ERROR_CODE_SUCCESS
1895 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1896 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1897 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1898 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1899 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1900 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1901 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1902 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1903 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1904 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1905 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1906 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1907 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1908 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1909 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1910 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1911 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1912 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1913 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1914 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1915 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1916 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1917 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1918 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1919 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1920 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1921 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1922 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1923 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1924 /// * RED_BRICK_FILE_TYPE_UNKNOWN
1925 /// * RED_BRICK_FILE_TYPE_REGULAR
1926 /// * RED_BRICK_FILE_TYPE_DIRECTORY
1927 /// * RED_BRICK_FILE_TYPE_CHARACTER
1928 /// * RED_BRICK_FILE_TYPE_BLOCK
1929 /// * RED_BRICK_FILE_TYPE_FIFO
1930 /// * RED_BRICK_FILE_TYPE_SYMLINK
1931 /// * RED_BRICK_FILE_TYPE_SOCKET
1932 /// * RED_BRICK_FILE_TYPE_PIPE
1933 /// * RED_BRICK_FILE_FLAG_READ_ONLY
1934 /// * RED_BRICK_FILE_FLAG_WRITE_ONLY
1935 /// * RED_BRICK_FILE_FLAG_READ_WRITE
1936 /// * RED_BRICK_FILE_FLAG_APPEND
1937 /// * RED_BRICK_FILE_FLAG_CREATE
1938 /// * RED_BRICK_FILE_FLAG_EXCLUSIVE
1939 /// * RED_BRICK_FILE_FLAG_NON_BLOCKING
1940 /// * RED_BRICK_FILE_FLAG_TRUNCATE
1941 /// * RED_BRICK_FILE_FLAG_TEMPORARY
1942 /// * RED_BRICK_FILE_FLAG_REPLACE
1943 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
1944 /// * RED_BRICK_FILE_PERMISSION_USER_READ
1945 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
1946 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
1947 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
1948 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
1949 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
1950 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
1951 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
1952 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
1953 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
1954 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
1955 pub fn get_file_info(&self, file_id: u16, session_id: u16) -> ConvertingReceiver<FileInfo> {
1956 let mut payload = vec![0; 4];
1957 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
1958 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
1959
1960 self.device.get(u8::from(RedBrickFunction::GetFileInfo), payload)
1961 }
1962
1963 /// Reads up to 62 bytes from a file object.
1964 ///
1965 /// Returns the bytes read, the actual number of bytes read and the resulting
1966 /// error code.
1967 ///
1968 /// If there is not data to be read, either because the file position reached
1969 /// end-of-file or because there is not data in the pipe, then zero bytes are
1970 /// returned.
1971 ///
1972 /// If the file object was created by [`open_file`] without the *NonBlocking*
1973 /// flag or by [`create_pipe`] without the *NonBlockingRead* flag then the
1974 /// error code *NotSupported* is returned.
1975 ///
1976 /// Associated constants:
1977 /// * RED_BRICK_ERROR_CODE_SUCCESS
1978 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1979 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1980 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1981 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1982 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1983 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1984 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1985 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1986 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1987 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1988 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1989 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1990 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1991 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1992 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1993 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1994 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1995 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1996 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1997 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1998 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1999 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2000 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2001 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2002 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2003 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2004 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2005 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2006 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2007 pub fn read_file(&self, file_id: u16, length_to_read: u8) -> ConvertingReceiver<ReadFile> {
2008 let mut payload = vec![0; 3];
2009 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2010 payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(length_to_read));
2011
2012 self.device.get(u8::from(RedBrickFunction::ReadFile), payload)
2013 }
2014
2015 /// Reads up to 2\ :sup:`63`\ - 1 bytes from a file object asynchronously.
2016 ///
2017 /// Reports the bytes read (in 60 byte chunks), the actual number of bytes read and
2018 /// the resulting error code via the [`get_async_file_read_callback_receiver`] receiver.
2019 ///
2020 /// If there is not data to be read, either because the file position reached
2021 /// end-of-file or because there is not data in the pipe, then zero bytes are
2022 /// reported.
2023 ///
2024 /// If the file object was created by [`open_file`] without the *NonBlocking*
2025 /// flag or by [`create_pipe`] without the *NonBlockingRead* flag then the error
2026 /// code *NotSupported* is reported via the [`get_async_file_read_callback_receiver`] receiver.
2027 pub fn read_file_async(&self, file_id: u16, length_to_read: u64) -> ConvertingReceiver<()> {
2028 let mut payload = vec![0; 10];
2029 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2030 payload[2..10].copy_from_slice(&<u64>::to_le_byte_vec(length_to_read));
2031
2032 self.device.set(u8::from(RedBrickFunction::ReadFileAsync), payload)
2033 }
2034
2035 /// Aborts a [`read_file_async`] operation in progress.
2036 ///
2037 /// Returns the resulting error code.
2038 ///
2039 /// On success the [`get_async_file_read_callback_receiver`] receiver will report *OperationAborted*.
2040 ///
2041 /// Associated constants:
2042 /// * RED_BRICK_ERROR_CODE_SUCCESS
2043 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2044 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2045 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2046 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2047 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2048 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2049 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2050 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2051 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2052 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2053 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2054 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2055 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2056 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2057 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2058 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2059 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2060 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2061 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2062 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2063 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2064 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2065 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2066 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2067 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2068 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2069 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2070 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2071 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2072 pub fn abort_async_file_read(&self, file_id: u16) -> ConvertingReceiver<u8> {
2073 let mut payload = vec![0; 2];
2074 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2075
2076 self.device.get(u8::from(RedBrickFunction::AbortAsyncFileRead), payload)
2077 }
2078
2079 /// Writes up to 61 bytes to a file object.
2080 ///
2081 /// Returns the actual number of bytes written and the resulting error code.
2082 ///
2083 /// If the file object was created by [`open_file`] without the *NonBlocking*
2084 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2085 /// error code *NotSupported* is returned.
2086 ///
2087 /// Associated constants:
2088 /// * RED_BRICK_ERROR_CODE_SUCCESS
2089 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2090 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2091 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2092 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2093 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2094 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2095 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2096 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2097 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2098 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2099 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2100 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2101 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2102 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2103 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2104 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2105 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2106 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2107 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2108 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2109 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2110 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2111 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2112 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2113 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2114 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2115 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2116 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2117 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2118 pub fn write_file(&self, file_id: u16, buffer: [u8; 61], length_to_write: u8) -> ConvertingReceiver<WriteFile> {
2119 let mut payload = vec![0; 64];
2120 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2121 payload[2..63].copy_from_slice(&<[u8; 61]>::to_le_byte_vec(buffer));
2122 payload[63..64].copy_from_slice(&<u8>::to_le_byte_vec(length_to_write));
2123
2124 self.device.get(u8::from(RedBrickFunction::WriteFile), payload)
2125 }
2126
2127 /// Writes up to 61 bytes to a file object.
2128 ///
2129 /// Does neither report the actual number of bytes written nor the resulting error
2130 /// code.
2131 ///
2132 /// If the file object was created by [`open_file`] without the *NonBlocking*
2133 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2134 /// write operation will fail silently.
2135 pub fn write_file_unchecked(&self, file_id: u16, buffer: [u8; 61], length_to_write: u8) -> ConvertingReceiver<()> {
2136 let mut payload = vec![0; 64];
2137 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2138 payload[2..63].copy_from_slice(&<[u8; 61]>::to_le_byte_vec(buffer));
2139 payload[63..64].copy_from_slice(&<u8>::to_le_byte_vec(length_to_write));
2140
2141 self.device.set(u8::from(RedBrickFunction::WriteFileUnchecked), payload)
2142 }
2143
2144 /// Writes up to 61 bytes to a file object.
2145 ///
2146 /// Reports the actual number of bytes written and the resulting error code via the
2147 /// [`get_async_file_write_callback_receiver`] receiver.
2148 ///
2149 /// If the file object was created by [`open_file`] without the *NonBlocking*
2150 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2151 /// error code *NotSupported* is reported via the [`get_async_file_write_callback_receiver`] receiver.
2152 pub fn write_file_async(&self, file_id: u16, buffer: [u8; 61], length_to_write: u8) -> ConvertingReceiver<()> {
2153 let mut payload = vec![0; 64];
2154 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2155 payload[2..63].copy_from_slice(&<[u8; 61]>::to_le_byte_vec(buffer));
2156 payload[63..64].copy_from_slice(&<u8>::to_le_byte_vec(length_to_write));
2157
2158 self.device.set(u8::from(RedBrickFunction::WriteFileAsync), payload)
2159 }
2160
2161 /// Set the current seek position of a file object relative to ``origin``.
2162 ///
2163 /// Possible file origins are:
2164 ///
2165 /// * Beginning = 0
2166 /// * Current = 1
2167 /// * End = 2
2168 ///
2169 /// Returns the resulting absolute seek position and error code.
2170 ///
2171 /// If the file object was created by [`create_pipe`] then it has no seek
2172 /// position and the error code *InvalidSeek* is returned.
2173 ///
2174 /// Associated constants:
2175 /// * RED_BRICK_FILE_ORIGIN_BEGINNING
2176 /// * RED_BRICK_FILE_ORIGIN_CURRENT
2177 /// * RED_BRICK_FILE_ORIGIN_END
2178 /// * RED_BRICK_ERROR_CODE_SUCCESS
2179 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2180 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2181 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2182 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2183 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2184 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2185 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2186 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2187 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2188 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2189 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2190 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2191 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2192 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2193 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2194 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2195 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2196 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2197 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2198 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2199 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2200 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2201 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2202 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2203 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2204 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2205 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2206 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2207 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2208 pub fn set_file_position(&self, file_id: u16, offset: i64, origin: u8) -> ConvertingReceiver<SetFilePosition> {
2209 let mut payload = vec![0; 11];
2210 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2211 payload[2..10].copy_from_slice(&<i64>::to_le_byte_vec(offset));
2212 payload[10..11].copy_from_slice(&<u8>::to_le_byte_vec(origin));
2213
2214 self.device.get(u8::from(RedBrickFunction::SetFilePosition), payload)
2215 }
2216
2217 /// Returns the current seek position of a file object and returns the
2218 /// resulting error code.
2219 ///
2220 /// If the file object was created by [`create_pipe`] then it has no seek
2221 /// position and the error code *InvalidSeek* is returned.
2222 ///
2223 /// Associated constants:
2224 /// * RED_BRICK_ERROR_CODE_SUCCESS
2225 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2226 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2227 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2228 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2229 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2230 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2231 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2232 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2233 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2234 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2235 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2236 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2237 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2238 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2239 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2240 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2241 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2242 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2243 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2244 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2245 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2246 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2247 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2248 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2249 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2250 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2251 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2252 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2253 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2254 pub fn get_file_position(&self, file_id: u16) -> ConvertingReceiver<FilePosition> {
2255 let mut payload = vec![0; 2];
2256 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2257
2258 self.device.get(u8::from(RedBrickFunction::GetFilePosition), payload)
2259 }
2260
2261 ///
2262 ///
2263 /// Associated constants:
2264 /// * RED_BRICK_FILE_EVENT_READABLE
2265 /// * RED_BRICK_FILE_EVENT_WRITABLE
2266 /// * RED_BRICK_ERROR_CODE_SUCCESS
2267 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2268 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2269 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2270 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2271 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2272 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2273 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2274 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2275 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2276 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2277 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2278 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2279 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2280 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2281 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2282 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2283 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2284 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2285 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2286 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2287 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2288 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2289 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2290 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2291 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2292 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2293 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2294 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2295 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2296 pub fn set_file_events(&self, file_id: u16, events: u16) -> ConvertingReceiver<u8> {
2297 let mut payload = vec![0; 4];
2298 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2299 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(events));
2300
2301 self.device.get(u8::from(RedBrickFunction::SetFileEvents), payload)
2302 }
2303
2304 ///
2305 ///
2306 /// Associated constants:
2307 /// * RED_BRICK_ERROR_CODE_SUCCESS
2308 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2309 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2310 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2311 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2312 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2313 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2314 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2315 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2316 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2317 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2318 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2319 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2320 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2321 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2322 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2323 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2324 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2325 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2326 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2327 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2328 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2329 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2330 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2331 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2332 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2333 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2334 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2335 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2336 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2337 /// * RED_BRICK_FILE_EVENT_READABLE
2338 /// * RED_BRICK_FILE_EVENT_WRITABLE
2339 pub fn get_file_events(&self, file_id: u16) -> ConvertingReceiver<FileEvents> {
2340 let mut payload = vec![0; 2];
2341 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(file_id));
2342
2343 self.device.get(u8::from(RedBrickFunction::GetFileEvents), payload)
2344 }
2345
2346 /// Opens an existing directory and allocates a new directory object for it.
2347 ///
2348 /// FIXME: name has to be absolute
2349 ///
2350 /// The reference count of the name string object is increased by one. When the
2351 /// directory object is destroyed then the reference count of the name string
2352 /// object is decreased by one. Also the name string object is locked and cannot be
2353 /// modified while the directory object holds a reference to it.
2354 ///
2355 /// Returns the object ID of the new directory object and the resulting error code.
2356 ///
2357 /// Associated constants:
2358 /// * RED_BRICK_ERROR_CODE_SUCCESS
2359 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2360 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2361 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2362 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2363 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2364 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2365 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2366 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2367 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2368 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2369 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2370 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2371 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2372 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2373 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2374 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2375 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2376 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2377 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2378 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2379 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2380 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2381 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2382 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2383 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2384 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2385 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2386 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2387 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2388 pub fn open_directory(&self, name_string_id: u16, session_id: u16) -> ConvertingReceiver<OpenDirectory> {
2389 let mut payload = vec![0; 4];
2390 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
2391 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2392
2393 self.device.get(u8::from(RedBrickFunction::OpenDirectory), payload)
2394 }
2395
2396 /// Returns the name of a directory object, as passed to [`open_directory`], and
2397 /// the resulting error code.
2398 ///
2399 /// Associated constants:
2400 /// * RED_BRICK_ERROR_CODE_SUCCESS
2401 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2402 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2403 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2404 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2405 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2406 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2407 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2408 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2409 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2410 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2411 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2412 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2413 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2414 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2415 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2416 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2417 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2418 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2419 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2420 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2421 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2422 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2423 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2424 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2425 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2426 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2427 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2428 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2429 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2430 pub fn get_directory_name(&self, directory_id: u16, session_id: u16) -> ConvertingReceiver<DirectoryName> {
2431 let mut payload = vec![0; 4];
2432 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(directory_id));
2433 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2434
2435 self.device.get(u8::from(RedBrickFunction::GetDirectoryName), payload)
2436 }
2437
2438 /// Returns the next entry in a directory object and the resulting error code.
2439 ///
2440 /// If there is not next entry then error code *NoMoreData* is returned. To rewind
2441 /// a directory object call [`rewind_directory`].
2442 ///
2443 /// Possible directory entry types are:
2444 ///
2445 /// * Unknown = 0
2446 /// * Regular = 1
2447 /// * Directory = 2
2448 /// * Character = 3
2449 /// * Block = 4
2450 /// * FIFO = 5
2451 /// * Symlink = 6
2452 /// * Socket = 7
2453 ///
2454 /// Associated constants:
2455 /// * RED_BRICK_ERROR_CODE_SUCCESS
2456 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2457 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2458 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2459 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2460 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2461 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2462 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2463 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2464 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2465 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2466 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2467 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2468 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2469 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2470 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2471 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2472 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2473 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2474 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2475 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2476 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2477 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2478 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2479 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2480 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2481 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2482 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2483 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2484 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2485 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_UNKNOWN
2486 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_REGULAR
2487 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_DIRECTORY
2488 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_CHARACTER
2489 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_BLOCK
2490 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_FIFO
2491 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_SYMLINK
2492 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_SOCKET
2493 pub fn get_next_directory_entry(&self, directory_id: u16, session_id: u16) -> ConvertingReceiver<NextDirectoryEntry> {
2494 let mut payload = vec![0; 4];
2495 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(directory_id));
2496 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2497
2498 self.device.get(u8::from(RedBrickFunction::GetNextDirectoryEntry), payload)
2499 }
2500
2501 /// Rewinds a directory object and returns the resulting error code.
2502 ///
2503 /// Associated constants:
2504 /// * RED_BRICK_ERROR_CODE_SUCCESS
2505 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2506 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2507 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2508 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2509 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2510 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2511 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2512 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2513 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2514 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2515 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2516 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2517 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2518 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2519 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2520 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2521 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2522 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2523 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2524 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2525 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2526 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2527 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2528 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2529 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2530 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2531 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2532 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2533 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2534 pub fn rewind_directory(&self, directory_id: u16) -> ConvertingReceiver<u8> {
2535 let mut payload = vec![0; 2];
2536 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(directory_id));
2537
2538 self.device.get(u8::from(RedBrickFunction::RewindDirectory), payload)
2539 }
2540
2541 /// FIXME: name has to be absolute
2542 ///
2543 /// Associated constants:
2544 /// * RED_BRICK_DIRECTORY_FLAG_RECURSIVE
2545 /// * RED_BRICK_DIRECTORY_FLAG_EXCLUSIVE
2546 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
2547 /// * RED_BRICK_FILE_PERMISSION_USER_READ
2548 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
2549 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
2550 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
2551 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
2552 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
2553 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
2554 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
2555 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
2556 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
2557 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
2558 /// * RED_BRICK_ERROR_CODE_SUCCESS
2559 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2560 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2561 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2562 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2563 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2564 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2565 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2566 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2567 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2568 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2569 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2570 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2571 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2572 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2573 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2574 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2575 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2576 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2577 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2578 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2579 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2580 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2581 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2582 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2583 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2584 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2585 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2586 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2587 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2588 pub fn create_directory(&self, name_string_id: u16, flags: u32, permissions: u16, uid: u32, gid: u32) -> ConvertingReceiver<u8> {
2589 let mut payload = vec![0; 16];
2590 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
2591 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(flags));
2592 payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(permissions));
2593 payload[8..12].copy_from_slice(&<u32>::to_le_byte_vec(uid));
2594 payload[12..16].copy_from_slice(&<u32>::to_le_byte_vec(gid));
2595
2596 self.device.get(u8::from(RedBrickFunction::CreateDirectory), payload)
2597 }
2598
2599 ///
2600 ///
2601 /// Associated constants:
2602 /// * RED_BRICK_ERROR_CODE_SUCCESS
2603 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2604 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2605 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2606 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2607 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2608 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2609 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2610 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2611 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2612 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2613 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2614 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2615 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2616 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2617 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2618 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2619 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2620 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2621 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2622 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2623 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2624 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2625 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2626 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2627 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2628 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2629 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2630 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2631 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2632 pub fn get_processes(&self, session_id: u16) -> ConvertingReceiver<Processes> {
2633 let mut payload = vec![0; 2];
2634 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2635
2636 self.device.get(u8::from(RedBrickFunction::GetProcesses), payload)
2637 }
2638
2639 ///
2640 ///
2641 /// Associated constants:
2642 /// * RED_BRICK_ERROR_CODE_SUCCESS
2643 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2644 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2645 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2646 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2647 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2648 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2649 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2650 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2651 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2652 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2653 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2654 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2655 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2656 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2657 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2658 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2659 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2660 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2661 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2662 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2663 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2664 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2665 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2666 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2667 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2668 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2669 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2670 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2671 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2672 pub fn spawn_process(
2673 &self,
2674 executable_string_id: u16,
2675 arguments_list_id: u16,
2676 environment_list_id: u16,
2677 working_directory_string_id: u16,
2678 uid: u32,
2679 gid: u32,
2680 stdin_file_id: u16,
2681 stdout_file_id: u16,
2682 stderr_file_id: u16,
2683 session_id: u16,
2684 ) -> ConvertingReceiver<SpawnProcess> {
2685 let mut payload = vec![0; 24];
2686 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(executable_string_id));
2687 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(arguments_list_id));
2688 payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(environment_list_id));
2689 payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(working_directory_string_id));
2690 payload[8..12].copy_from_slice(&<u32>::to_le_byte_vec(uid));
2691 payload[12..16].copy_from_slice(&<u32>::to_le_byte_vec(gid));
2692 payload[16..18].copy_from_slice(&<u16>::to_le_byte_vec(stdin_file_id));
2693 payload[18..20].copy_from_slice(&<u16>::to_le_byte_vec(stdout_file_id));
2694 payload[20..22].copy_from_slice(&<u16>::to_le_byte_vec(stderr_file_id));
2695 payload[22..24].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2696
2697 self.device.get(u8::from(RedBrickFunction::SpawnProcess), payload)
2698 }
2699
2700 /// Sends a UNIX signal to a process object and returns the resulting error code.
2701 ///
2702 /// Possible UNIX signals are:
2703 ///
2704 /// * Interrupt = 2
2705 /// * Quit = 3
2706 /// * Abort = 6
2707 /// * Kill = 9
2708 /// * User1 = 10
2709 /// * User2 = 12
2710 /// * Terminate = 15
2711 /// * Continue = 18
2712 /// * Stop = 19
2713 ///
2714 /// Associated constants:
2715 /// * RED_BRICK_PROCESS_SIGNAL_INTERRUPT
2716 /// * RED_BRICK_PROCESS_SIGNAL_QUIT
2717 /// * RED_BRICK_PROCESS_SIGNAL_ABORT
2718 /// * RED_BRICK_PROCESS_SIGNAL_KILL
2719 /// * RED_BRICK_PROCESS_SIGNAL_USER1
2720 /// * RED_BRICK_PROCESS_SIGNAL_USER2
2721 /// * RED_BRICK_PROCESS_SIGNAL_TERMINATE
2722 /// * RED_BRICK_PROCESS_SIGNAL_CONTINUE
2723 /// * RED_BRICK_PROCESS_SIGNAL_STOP
2724 /// * RED_BRICK_ERROR_CODE_SUCCESS
2725 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2726 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2727 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2728 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2729 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2730 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2731 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2732 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2733 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2734 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2735 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2736 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2737 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2738 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2739 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2740 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2741 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2742 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2743 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2744 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2745 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2746 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2747 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2748 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2749 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2750 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2751 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2752 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2753 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2754 pub fn kill_process(&self, process_id: u16, signal: u8) -> ConvertingReceiver<u8> {
2755 let mut payload = vec![0; 3];
2756 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(process_id));
2757 payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(signal));
2758
2759 self.device.get(u8::from(RedBrickFunction::KillProcess), payload)
2760 }
2761
2762 /// Returns the executable, arguments, environment and working directory used to
2763 /// spawn a process object, as passed to [`spawn_process`], and the resulting
2764 /// error code.
2765 ///
2766 /// Associated constants:
2767 /// * RED_BRICK_ERROR_CODE_SUCCESS
2768 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2769 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2770 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2771 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2772 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2773 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2774 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2775 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2776 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2777 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2778 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2779 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2780 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2781 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2782 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2783 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2784 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2785 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2786 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2787 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2788 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2789 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2790 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2791 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2792 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2793 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2794 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2795 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2796 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2797 pub fn get_process_command(&self, process_id: u16, session_id: u16) -> ConvertingReceiver<ProcessCommand> {
2798 let mut payload = vec![0; 4];
2799 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(process_id));
2800 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2801
2802 self.device.get(u8::from(RedBrickFunction::GetProcessCommand), payload)
2803 }
2804
2805 /// Returns the process ID and the user and group ID used to spawn a process object,
2806 /// as passed to [`spawn_process`], and the resulting error code.
2807 ///
2808 /// The process ID is only valid if the state is *Running* or *Stopped*, see
2809 /// [`get_process_state`].
2810 ///
2811 /// Associated constants:
2812 /// * RED_BRICK_ERROR_CODE_SUCCESS
2813 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2814 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2815 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2816 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2817 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2818 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2819 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2820 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2821 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2822 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2823 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2824 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2825 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2826 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2827 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2828 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2829 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2830 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2831 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2832 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2833 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2834 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2835 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2836 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2837 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2838 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2839 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2840 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2841 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2842 pub fn get_process_identity(&self, process_id: u16) -> ConvertingReceiver<ProcessIdentity> {
2843 let mut payload = vec![0; 2];
2844 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(process_id));
2845
2846 self.device.get(u8::from(RedBrickFunction::GetProcessIdentity), payload)
2847 }
2848
2849 /// Returns the stdin, stdout and stderr files used to spawn a process object, as
2850 /// passed to [`spawn_process`], and the resulting error code.
2851 ///
2852 /// Associated constants:
2853 /// * RED_BRICK_ERROR_CODE_SUCCESS
2854 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2855 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2856 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2857 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2858 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2859 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2860 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2861 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2862 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2863 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2864 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2865 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2866 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2867 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2868 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2869 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2870 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2871 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2872 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2873 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2874 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2875 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2876 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2877 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2878 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2879 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2880 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2881 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2882 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2883 pub fn get_process_stdio(&self, process_id: u16, session_id: u16) -> ConvertingReceiver<ProcessStdio> {
2884 let mut payload = vec![0; 4];
2885 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(process_id));
2886 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
2887
2888 self.device.get(u8::from(RedBrickFunction::GetProcessStdio), payload)
2889 }
2890
2891 /// Returns the current state, timestamp and exit code of a process object, and
2892 /// the resulting error code.
2893 ///
2894 /// Possible process states are:
2895 ///
2896 /// * Unknown = 0
2897 /// * Running = 1
2898 /// * Error = 2
2899 /// * Exited = 3
2900 /// * Killed = 4
2901 /// * Stopped = 5
2902 ///
2903 /// The timestamp represents the UNIX time since when the process is in its current
2904 /// state.
2905 ///
2906 /// The exit code is only valid if the state is *Error*, *Exited*, *Killed* or
2907 /// *Stopped* and has different meanings depending on the state:
2908 ///
2909 /// * Error: error code for error occurred while spawning the process (see below)
2910 /// * Exited: exit status of the process
2911 /// * Killed: UNIX signal number used to kill the process
2912 /// * Stopped: UNIX signal number used to stop the process
2913 ///
2914 /// Possible exit/error codes in *Error* state are:
2915 ///
2916 /// * InternalError = 125
2917 /// * CannotExecute = 126
2918 /// * DoesNotExist = 127
2919 ///
2920 /// The *CannotExecute* error can be caused by the executable being opened for
2921 /// writing.
2922 ///
2923 /// Associated constants:
2924 /// * RED_BRICK_ERROR_CODE_SUCCESS
2925 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2926 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2927 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2928 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2929 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2930 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2931 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2932 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2933 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2934 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2935 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2936 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2937 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2938 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2939 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2940 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2941 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2942 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2943 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2944 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2945 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2946 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2947 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2948 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2949 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2950 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2951 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2952 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2953 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2954 /// * RED_BRICK_PROCESS_STATE_UNKNOWN
2955 /// * RED_BRICK_PROCESS_STATE_RUNNING
2956 /// * RED_BRICK_PROCESS_STATE_ERROR
2957 /// * RED_BRICK_PROCESS_STATE_EXITED
2958 /// * RED_BRICK_PROCESS_STATE_KILLED
2959 /// * RED_BRICK_PROCESS_STATE_STOPPED
2960 pub fn get_process_state(&self, process_id: u16) -> ConvertingReceiver<ProcessState> {
2961 let mut payload = vec![0; 2];
2962 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(process_id));
2963
2964 self.device.get(u8::from(RedBrickFunction::GetProcessState), payload)
2965 }
2966
2967 ///
2968 ///
2969 /// Associated constants:
2970 /// * RED_BRICK_ERROR_CODE_SUCCESS
2971 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2972 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2973 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2974 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2975 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2976 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2977 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2978 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2979 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2980 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2981 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2982 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2983 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2984 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2985 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2986 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2987 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2988 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2989 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2990 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2991 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2992 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2993 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2994 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2995 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2996 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2997 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2998 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2999 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3000 pub fn get_programs(&self, session_id: u16) -> ConvertingReceiver<Programs> {
3001 let mut payload = vec![0; 2];
3002 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3003
3004 self.device.get(u8::from(RedBrickFunction::GetPrograms), payload)
3005 }
3006
3007 ///
3008 ///
3009 /// Associated constants:
3010 /// * RED_BRICK_ERROR_CODE_SUCCESS
3011 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3012 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3013 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3014 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3015 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3016 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3017 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3018 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3019 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3020 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3021 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3022 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3023 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3024 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3025 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3026 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3027 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3028 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3029 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3030 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3031 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3032 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3033 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3034 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3035 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3036 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3037 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3038 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3039 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3040 pub fn define_program(&self, identifier_string_id: u16, session_id: u16) -> ConvertingReceiver<DefineProgram> {
3041 let mut payload = vec![0; 4];
3042 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(identifier_string_id));
3043 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3044
3045 self.device.get(u8::from(RedBrickFunction::DefineProgram), payload)
3046 }
3047
3048 ///
3049 ///
3050 /// Associated constants:
3051 /// * RED_BRICK_ERROR_CODE_SUCCESS
3052 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3053 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3054 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3055 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3056 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3057 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3058 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3059 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3060 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3061 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3062 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3063 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3064 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3065 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3066 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3067 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3068 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3069 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3070 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3071 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3072 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3073 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3074 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3075 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3076 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3077 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3078 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3079 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3080 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3081 pub fn purge_program(&self, program_id: u16, cookie: u32) -> ConvertingReceiver<u8> {
3082 let mut payload = vec![0; 6];
3083 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3084 payload[2..6].copy_from_slice(&<u32>::to_le_byte_vec(cookie));
3085
3086 self.device.get(u8::from(RedBrickFunction::PurgeProgram), payload)
3087 }
3088
3089 ///
3090 ///
3091 /// Associated constants:
3092 /// * RED_BRICK_ERROR_CODE_SUCCESS
3093 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3094 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3095 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3096 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3097 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3098 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3099 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3100 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3101 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3102 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3103 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3104 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3105 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3106 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3107 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3108 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3109 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3110 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3111 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3112 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3113 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3114 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3115 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3116 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3117 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3118 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3119 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3120 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3121 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3122 pub fn get_program_identifier(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramIdentifier> {
3123 let mut payload = vec![0; 4];
3124 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3125 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3126
3127 self.device.get(u8::from(RedBrickFunction::GetProgramIdentifier), payload)
3128 }
3129
3130 /// FIXME: root directory is absolute: <home>/programs/<identifier>
3131 ///
3132 /// Associated constants:
3133 /// * RED_BRICK_ERROR_CODE_SUCCESS
3134 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3135 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3136 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3137 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3138 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3139 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3140 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3141 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3142 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3143 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3144 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3145 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3146 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3147 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3148 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3149 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3150 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3151 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3152 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3153 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3154 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3155 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3156 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3157 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3158 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3159 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3160 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3161 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3162 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3163 pub fn get_program_root_directory(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramRootDirectory> {
3164 let mut payload = vec![0; 4];
3165 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3166 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3167
3168 self.device.get(u8::from(RedBrickFunction::GetProgramRootDirectory), payload)
3169 }
3170
3171 /// FIXME: working directory is relative to <home>/programs/<identifier>/bin
3172 ///
3173 /// Associated constants:
3174 /// * RED_BRICK_ERROR_CODE_SUCCESS
3175 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3176 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3177 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3178 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3179 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3180 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3181 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3182 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3183 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3184 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3185 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3186 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3187 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3188 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3189 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3190 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3191 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3192 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3193 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3194 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3195 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3196 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3197 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3198 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3199 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3200 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3201 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3202 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3203 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3204 pub fn set_program_command(
3205 &self,
3206 program_id: u16,
3207 executable_string_id: u16,
3208 arguments_list_id: u16,
3209 environment_list_id: u16,
3210 working_directory_string_id: u16,
3211 ) -> ConvertingReceiver<u8> {
3212 let mut payload = vec![0; 10];
3213 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3214 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(executable_string_id));
3215 payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(arguments_list_id));
3216 payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(environment_list_id));
3217 payload[8..10].copy_from_slice(&<u16>::to_le_byte_vec(working_directory_string_id));
3218
3219 self.device.get(u8::from(RedBrickFunction::SetProgramCommand), payload)
3220 }
3221
3222 /// FIXME: working directory is relative to <home>/programs/<identifier>/bin
3223 ///
3224 /// Associated constants:
3225 /// * RED_BRICK_ERROR_CODE_SUCCESS
3226 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3227 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3228 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3229 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3230 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3231 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3232 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3233 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3234 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3235 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3236 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3237 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3238 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3239 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3240 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3241 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3242 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3243 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3244 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3245 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3246 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3247 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3248 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3249 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3250 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3251 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3252 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3253 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3254 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3255 pub fn get_program_command(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramCommand> {
3256 let mut payload = vec![0; 4];
3257 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3258 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3259
3260 self.device.get(u8::from(RedBrickFunction::GetProgramCommand), payload)
3261 }
3262
3263 /// FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
3264 ///
3265 /// Associated constants:
3266 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL
3267 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE
3268 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE
3269 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG
3270 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG
3271 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT
3272 /// * RED_BRICK_ERROR_CODE_SUCCESS
3273 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3274 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3275 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3276 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3277 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3278 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3279 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3280 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3281 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3282 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3283 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3284 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3285 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3286 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3287 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3288 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3289 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3290 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3291 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3292 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3293 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3294 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3295 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3296 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3297 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3298 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3299 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3300 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3301 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3302 pub fn set_program_stdio_redirection(
3303 &self,
3304 program_id: u16,
3305 stdin_redirection: u8,
3306 stdin_file_name_string_id: u16,
3307 stdout_redirection: u8,
3308 stdout_file_name_string_id: u16,
3309 stderr_redirection: u8,
3310 stderr_file_name_string_id: u16,
3311 ) -> ConvertingReceiver<u8> {
3312 let mut payload = vec![0; 11];
3313 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3314 payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(stdin_redirection));
3315 payload[3..5].copy_from_slice(&<u16>::to_le_byte_vec(stdin_file_name_string_id));
3316 payload[5..6].copy_from_slice(&<u8>::to_le_byte_vec(stdout_redirection));
3317 payload[6..8].copy_from_slice(&<u16>::to_le_byte_vec(stdout_file_name_string_id));
3318 payload[8..9].copy_from_slice(&<u8>::to_le_byte_vec(stderr_redirection));
3319 payload[9..11].copy_from_slice(&<u16>::to_le_byte_vec(stderr_file_name_string_id));
3320
3321 self.device.get(u8::from(RedBrickFunction::SetProgramStdioRedirection), payload)
3322 }
3323
3324 /// FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
3325 ///
3326 /// Associated constants:
3327 /// * RED_BRICK_ERROR_CODE_SUCCESS
3328 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3329 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3330 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3331 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3332 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3333 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3334 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3335 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3336 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3337 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3338 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3339 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3340 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3341 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3342 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3343 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3344 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3345 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3346 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3347 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3348 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3349 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3350 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3351 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3352 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3353 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3354 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3355 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3356 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3357 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL
3358 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE
3359 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE
3360 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG
3361 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG
3362 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT
3363 pub fn get_program_stdio_redirection(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramStdioRedirection> {
3364 let mut payload = vec![0; 4];
3365 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3366 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3367
3368 self.device.get(u8::from(RedBrickFunction::GetProgramStdioRedirection), payload)
3369 }
3370
3371 ///
3372 ///
3373 /// Associated constants:
3374 /// * RED_BRICK_PROGRAM_START_MODE_NEVER
3375 /// * RED_BRICK_PROGRAM_START_MODE_ALWAYS
3376 /// * RED_BRICK_PROGRAM_START_MODE_INTERVAL
3377 /// * RED_BRICK_PROGRAM_START_MODE_CRON
3378 /// * RED_BRICK_ERROR_CODE_SUCCESS
3379 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3380 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3381 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3382 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3383 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3384 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3385 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3386 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3387 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3388 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3389 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3390 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3391 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3392 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3393 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3394 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3395 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3396 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3397 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3398 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3399 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3400 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3401 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3402 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3403 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3404 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3405 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3406 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3407 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3408 pub fn set_program_schedule(
3409 &self,
3410 program_id: u16,
3411 start_mode: u8,
3412 continue_after_error: bool,
3413 start_interval: u32,
3414 start_fields_string_id: u16,
3415 ) -> ConvertingReceiver<u8> {
3416 let mut payload = vec![0; 10];
3417 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3418 payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(start_mode));
3419 payload[3..4].copy_from_slice(&<bool>::to_le_byte_vec(continue_after_error));
3420 payload[4..8].copy_from_slice(&<u32>::to_le_byte_vec(start_interval));
3421 payload[8..10].copy_from_slice(&<u16>::to_le_byte_vec(start_fields_string_id));
3422
3423 self.device.get(u8::from(RedBrickFunction::SetProgramSchedule), payload)
3424 }
3425
3426 ///
3427 ///
3428 /// Associated constants:
3429 /// * RED_BRICK_ERROR_CODE_SUCCESS
3430 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3431 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3432 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3433 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3434 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3435 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3436 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3437 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3438 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3439 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3440 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3441 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3442 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3443 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3444 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3445 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3446 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3447 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3448 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3449 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3450 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3451 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3452 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3453 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3454 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3455 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3456 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3457 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3458 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3459 /// * RED_BRICK_PROGRAM_START_MODE_NEVER
3460 /// * RED_BRICK_PROGRAM_START_MODE_ALWAYS
3461 /// * RED_BRICK_PROGRAM_START_MODE_INTERVAL
3462 /// * RED_BRICK_PROGRAM_START_MODE_CRON
3463 pub fn get_program_schedule(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramSchedule> {
3464 let mut payload = vec![0; 4];
3465 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3466 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3467
3468 self.device.get(u8::from(RedBrickFunction::GetProgramSchedule), payload)
3469 }
3470
3471 /// FIXME: message is currently valid in error-occurred state only
3472 ///
3473 /// Associated constants:
3474 /// * RED_BRICK_ERROR_CODE_SUCCESS
3475 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3476 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3477 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3478 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3479 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3480 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3481 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3482 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3483 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3484 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3485 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3486 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3487 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3488 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3489 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3490 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3491 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3492 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3493 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3494 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3495 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3496 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3497 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3498 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3499 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3500 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3501 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3502 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3503 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3504 /// * RED_BRICK_PROGRAM_SCHEDULER_STATE_STOPPED
3505 /// * RED_BRICK_PROGRAM_SCHEDULER_STATE_RUNNING
3506 pub fn get_program_scheduler_state(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<ProgramSchedulerState> {
3507 let mut payload = vec![0; 4];
3508 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3509 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3510
3511 self.device.get(u8::from(RedBrickFunction::GetProgramSchedulerState), payload)
3512 }
3513
3514 ///
3515 ///
3516 /// Associated constants:
3517 /// * RED_BRICK_ERROR_CODE_SUCCESS
3518 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3519 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3520 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3521 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3522 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3523 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3524 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3525 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3526 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3527 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3528 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3529 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3530 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3531 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3532 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3533 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3534 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3535 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3536 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3537 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3538 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3539 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3540 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3541 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3542 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3543 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3544 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3545 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3546 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3547 pub fn continue_program_schedule(&self, program_id: u16) -> ConvertingReceiver<u8> {
3548 let mut payload = vec![0; 2];
3549 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3550
3551 self.device.get(u8::from(RedBrickFunction::ContinueProgramSchedule), payload)
3552 }
3553
3554 ///
3555 ///
3556 /// Associated constants:
3557 /// * RED_BRICK_ERROR_CODE_SUCCESS
3558 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3559 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3560 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3561 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3562 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3563 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3564 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3565 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3566 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3567 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3568 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3569 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3570 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3571 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3572 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3573 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3574 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3575 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3576 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3577 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3578 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3579 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3580 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3581 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3582 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3583 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3584 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3585 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3586 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3587 pub fn start_program(&self, program_id: u16) -> ConvertingReceiver<u8> {
3588 let mut payload = vec![0; 2];
3589 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3590
3591 self.device.get(u8::from(RedBrickFunction::StartProgram), payload)
3592 }
3593
3594 ///
3595 ///
3596 /// Associated constants:
3597 /// * RED_BRICK_ERROR_CODE_SUCCESS
3598 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3599 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3600 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3601 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3602 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3603 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3604 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3605 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3606 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3607 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3608 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3609 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3610 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3611 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3612 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3613 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3614 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3615 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3616 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3617 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3618 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3619 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3620 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3621 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3622 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3623 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3624 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3625 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3626 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3627 pub fn get_last_spawned_program_process(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<LastSpawnedProgramProcess> {
3628 let mut payload = vec![0; 4];
3629 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3630 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3631
3632 self.device.get(u8::from(RedBrickFunction::GetLastSpawnedProgramProcess), payload)
3633 }
3634
3635 ///
3636 ///
3637 /// Associated constants:
3638 /// * RED_BRICK_ERROR_CODE_SUCCESS
3639 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3640 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3641 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3642 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3643 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3644 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3645 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3646 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3647 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3648 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3649 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3650 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3651 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3652 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3653 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3654 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3655 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3656 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3657 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3658 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3659 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3660 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3661 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3662 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3663 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3664 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3665 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3666 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3667 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3668 pub fn get_custom_program_option_names(&self, program_id: u16, session_id: u16) -> ConvertingReceiver<CustomProgramOptionNames> {
3669 let mut payload = vec![0; 4];
3670 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3671 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3672
3673 self.device.get(u8::from(RedBrickFunction::GetCustomProgramOptionNames), payload)
3674 }
3675
3676 ///
3677 ///
3678 /// Associated constants:
3679 /// * RED_BRICK_ERROR_CODE_SUCCESS
3680 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3681 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3682 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3683 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3684 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3685 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3686 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3687 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3688 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3689 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3690 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3691 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3692 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3693 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3694 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3695 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3696 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3697 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3698 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3699 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3700 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3701 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3702 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3703 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3704 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3705 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3706 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3707 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3708 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3709 pub fn set_custom_program_option_value(&self, program_id: u16, name_string_id: u16, value_string_id: u16) -> ConvertingReceiver<u8> {
3710 let mut payload = vec![0; 6];
3711 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3712 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
3713 payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(value_string_id));
3714
3715 self.device.get(u8::from(RedBrickFunction::SetCustomProgramOptionValue), payload)
3716 }
3717
3718 ///
3719 ///
3720 /// Associated constants:
3721 /// * RED_BRICK_ERROR_CODE_SUCCESS
3722 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3723 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3724 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3725 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3726 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3727 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3728 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3729 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3730 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3731 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3732 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3733 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3734 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3735 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3736 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3737 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3738 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3739 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3740 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3741 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3742 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3743 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3744 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3745 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3746 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3747 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3748 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3749 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3750 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3751 pub fn get_custom_program_option_value(
3752 &self,
3753 program_id: u16,
3754 name_string_id: u16,
3755 session_id: u16,
3756 ) -> ConvertingReceiver<CustomProgramOptionValue> {
3757 let mut payload = vec![0; 6];
3758 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3759 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
3760 payload[4..6].copy_from_slice(&<u16>::to_le_byte_vec(session_id));
3761
3762 self.device.get(u8::from(RedBrickFunction::GetCustomProgramOptionValue), payload)
3763 }
3764
3765 ///
3766 ///
3767 /// Associated constants:
3768 /// * RED_BRICK_ERROR_CODE_SUCCESS
3769 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3770 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3771 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3772 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3773 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3774 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3775 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3776 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3777 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3778 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3779 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3780 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3781 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3782 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3783 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3784 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3785 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3786 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3787 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3788 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3789 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3790 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3791 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3792 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3793 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3794 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3795 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3796 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3797 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3798 pub fn remove_custom_program_option(&self, program_id: u16, name_string_id: u16) -> ConvertingReceiver<u8> {
3799 let mut payload = vec![0; 4];
3800 payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(program_id));
3801 payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(name_string_id));
3802
3803 self.device.get(u8::from(RedBrickFunction::RemoveCustomProgramOption), payload)
3804 }
3805
3806 /// Returns the UID, the UID where the Brick is connected to,
3807 /// the position, the hardware and firmware version as well as the
3808 /// device identifier.
3809 ///
3810 /// The position is the position in the stack from '0' (bottom) to '8' (top).
3811 ///
3812 /// The device identifier numbers can be found [here](device_identifier).
3813 /// |device_identifier_constant|
3814 pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
3815 let payload = vec![0; 0];
3816
3817 self.device.get(u8::from(RedBrickFunction::GetIdentity), payload)
3818 }
3819}