|
1 | | -# 1Password IPC Client |
| 1 | +# 1Password IPC Client |
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
@@ -68,62 +68,6 @@ let response2 = send_with_pipe(&mut pipe, request2).unwrap(); |
68 | 68 |
|
69 | 69 | Note: Windows and Linux have a limitation in multi-threaded environments with message integrity. Users must ensure they send and receive one at a time. |
70 | 70 |
|
71 | | -## Public API |
72 | | - |
73 | | -### `send_to` |
74 | | - |
75 | | -```rust |
76 | | -pub fn send_to(endpoint_name: &str, message: Vec<u8>) -> Result<Vec<u8>, ErrorCode> |
77 | | -``` |
78 | | - |
79 | | -Sends a message to the IPC server at the given endpoint and returns the response. This is a synchronous, blocking call that creates a fresh connection per invocation. |
80 | | - |
81 | | -| Parameter | Type | Description | |
82 | | -| :-------- | :--- | :---------- | |
83 | | -| endpoint_name | `&str` | The endpoint to connect to. Interpreted as a Mach port name on macOS, an abstract Unix socket name on Linux, or a named pipe path on Windows. | |
84 | | -| message | `Vec<u8>` | The raw request bytes to send | |
85 | | - |
86 | | -**Returns:** `Ok(Vec<u8>)` containing the response bytes, or `Err(ErrorCode)` on failure. |
87 | | - |
88 | | -### `send_with_client` (macOS only) |
89 | | - |
90 | | -```rust |
91 | | -pub fn send_with_client(client: &mut Client, request: Vec<u8>) -> Result<Vec<u8>, ErrorCode> |
92 | | -``` |
93 | | - |
94 | | -Sends a message over an existing Mach port client. Allows reusing the same connection across multiple calls. |
95 | | - |
96 | | -### `send_with_stream` (Linux only) |
97 | | - |
98 | | -```rust |
99 | | -pub fn send_with_stream(stream: &mut UnixStream, message: Vec<u8>) -> Result<Vec<u8>, ErrorCode> |
100 | | -``` |
101 | | - |
102 | | -Sends a message over an existing Unix stream. Allows reusing the same connection across multiple calls. |
103 | | - |
104 | | -### `send_with_pipe` (Windows only) |
105 | | - |
106 | | -```rust |
107 | | -pub fn send_with_pipe(pipe: &mut File, message: Vec<u8>) -> Result<Vec<u8>, ErrorCode> |
108 | | -``` |
109 | | - |
110 | | -Sends a message over an existing named pipe. Allows reusing the same connection across multiple calls. |
111 | | - |
112 | | -## Error Handling |
113 | | - |
114 | | -All platforms share a single `ErrorCode` enum, re-exported from the crate root as `onepassword_ipc_client::ErrorCode`. |
115 | | - |
116 | | -| Value | Description | |
117 | | -| :---- | :---------- | |
118 | | -| `InvalidArguments` | Invalid arguments were provided (e.g. bad endpoint name). | |
119 | | -| `FailedToConnect` | Failed to connect to the IPC endpoint. | |
120 | | -| `FailedToSend` | Failed to send the message. | |
121 | | -| `FailedToReceive` | Failed to receive a response from the server. | |
122 | | -| `FailedToEncode` | Failed to encode the message into the wire format. | |
123 | | -| `FailedToDecode` | Failed to decode the response from the wire format. | |
124 | | -| `ServerClosedConnection` | The server closed the connection unexpectedly. | |
125 | | -| `Internal` | An internal error occurred. | |
126 | | - |
127 | 71 | ## Wire Protocol |
128 | 72 |
|
129 | 73 | ### Framing (Linux / Windows) |
@@ -173,3 +117,19 @@ The maximum chunk size is 500,000 bytes (1-byte header + up to 499,999 bytes of |
173 | 117 |
|
174 | 118 | On macOS, if the server's response spans multiple chunks, the client sends a dummy (empty) chunk after each intermediate response chunk to request the next one. On Linux and Windows, all response chunks are sent by the server without further prompting. |
175 | 119 |
|
| 120 | +## Credits |
| 121 | + |
| 122 | +Made with ❤️ and ☕ by the [1Password](https://1password.com/) team. |
| 123 | + |
| 124 | +### License |
| 125 | + |
| 126 | +<sup> |
| 127 | +Licensed under either of <a href="LICENSE-APACHE">Apache License, Version |
| 128 | +2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option. |
| 129 | +</sup> |
| 130 | + |
| 131 | +<sub> |
| 132 | +Unless you explicitly state otherwise, any contribution intentionally submitted |
| 133 | +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 134 | +be dual licensed as above, without any additional terms or conditions. |
| 135 | +</sub> |
0 commit comments