Skip to content

Commit c04ef0a

Browse files
committed
Small documentation update.
1 parent d684b6e commit c04ef0a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ type QuoteResult = (JsonValue, Vec<u8>, Option<JsonValue>, Option<String>);
6767
///
6868
/// ### Thread Safety
6969
///
70-
/// `FapiContext` implements the `Send` trait, so it may be transferred to another thread. However, it does **not** implement the `Sync` trait! Hence, in order to share a `FapiContext` between multiple concurrent threads, wrapping the context in an `Arc<Mutex<_>>` is required. This effectively ensures that *at most* **one** thread at a time can access the "shared" `FapiContext`.
70+
/// In general, the FAPI is considered “thread-safe”, but individual instances of `FapiContext` are **not**.
71+
///
72+
/// This means that an application may safely access the FAPI from multiple *concurrent* threads, provided that each of these threads uses its own separate `FapiContext` instance. Sharing the same `FapiContext` instance between *concurrent* threads is also possible, but this requires an explicit synchronization to ensure that *at most* **one** thread at a time will access the "shared" instance! Specifically, `FapiContext` implements the [`Send`] trait, so it may be transferred to another thread, but it does **not** implement the [`Sync`] trait. However, you can wrap the context in an `Arc<Mutex<T>>` in order to share it safely between multiple threads.
73+
///
74+
/// By default, the `tss2-fapi-rs` library does **not** serialize FAPI calls from *concurrent* application threads, except for a few “critical” functions. The optional **`full_locking`** feature can be enabled to enforce the serialization of *all* FAPI calls.
7175
///
7276
/// ### FAPI Library
7377
///

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* All rights reserved.
55
**********************************************************************************************/
66

7-
//! [![Rust](https://img.shields.io/badge/rust-1.79.0+-orchid?logo=rust)](https://www.rust-lang.org/)
7+
//! [![Rust](https://img.shields.io/badge/rust-1.82.0+-orchid?logo=rust)](https://www.rust-lang.org/)
88
//! [![Crates.io](https://img.shields.io/crates/v/tss2-fapi-rs.svg)](https://crates.io/crates/tss2-fapi-rs)
99
//! [![Docs.rs](https://img.shields.io/docsrs/tss2-fapi-rs.svg)](https://docs.rs/tss2-fapi-rs/latest/tss2_fapi_rs/)
1010
//! [![License](https://img.shields.io/crates/l/tss2-fapi-rs)](https://opensource.org/licenses/BSD-3-Clause)

src/marshal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* All rights reserved.
55
**********************************************************************************************/
66

7-
use std::{borrow::Cow, iter::repeat, mem::size_of};
7+
use std::{borrow::Cow, iter::repeat_n, mem::size_of};
88

99
const U64_SIZE: usize = size_of::<u64>();
1010

@@ -16,7 +16,7 @@ pub(crate) fn resize_be(bytes: &[u8], new_size: usize) -> Cow<'_, [u8]> {
1616
if bytes.len() >= new_size {
1717
Cow::Borrowed(&bytes[bytes.len() - new_size..])
1818
} else {
19-
Cow::Owned(repeat(0u8).take(new_size - bytes.len()).chain(bytes.iter().copied()).collect::<Vec<u8>>())
19+
Cow::Owned(repeat_n(0u8, new_size - bytes.len()).chain(bytes.iter().copied()).collect::<Vec<u8>>())
2020
}
2121
}
2222

0 commit comments

Comments
 (0)