Struct ouroboros_examples::DataAndRef
source · #[repr(transparent)]pub struct DataAndRef {
actual_data: MaybeUninit<DataAndRefInternal>,
}
Expand description
The self-referencing struct.
Fields§
§actual_data: MaybeUninit<DataAndRefInternal>
Implementations§
source§impl DataAndRef
impl DataAndRef
sourcepub(crate) fn new(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> &'this i32
) -> DataAndRef
pub(crate) fn new( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> &'this i32 ) -> DataAndRef
Constructs a new instance of this self-referential struct. (See also DataAndRefBuilder::build()
). Each argument is a field of the new struct. Fields that refer to other fields inside the struct are initialized using functions instead of directly passing their value. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> data_ref: _ |
sourcepub(crate) async fn new_async(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = &'this i32> + 'this>>
) -> DataAndRef
pub(crate) async fn new_async( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = &'this i32> + 'this>> ) -> DataAndRef
Constructs a new instance of this self-referential struct. (See also DataAndRefAsyncBuilder::build()
). Each argument is a field of the new struct. Fields that refer to other fields inside the struct are initialized using functions instead of directly passing their value. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> data_ref: _ |
sourcepub(crate) async fn new_async_send(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = &'this i32> + Send + 'this>>
) -> DataAndRef
pub(crate) async fn new_async_send( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = &'this i32> + Send + 'this>> ) -> DataAndRef
Constructs a new instance of this self-referential struct. (See also DataAndRefAsyncSendBuilder::build()
). Each argument is a field of the new struct. Fields that refer to other fields inside the struct are initialized using functions instead of directly passing their value. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> data_ref: _ |
sourcepub(crate) fn try_new<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Result<&'this i32, Error_>
) -> Result<DataAndRef, Error_>
pub(crate) fn try_new<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Result<&'this i32, Error_> ) -> Result<DataAndRef, Error_>
(See also DataAndRefTryBuilder::try_build()
.) Like new
, but builders for self-referencing fields can return results. If any of them fail, Err
is returned. If all of them succeed, Ok
is returned. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) fn try_new_or_recover<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Result<&'this i32, Error_>
) -> Result<DataAndRef, (Error_, Heads)>
pub(crate) fn try_new_or_recover<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Result<&'this i32, Error_> ) -> Result<DataAndRef, (Error_, Heads)>
(See also DataAndRefTryBuilder::try_build_or_recover()
.) Like try_new
, but all head fields are returned in the case of an error. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) async fn try_new_async<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + 'this>>
) -> Result<DataAndRef, Error_>
pub(crate) async fn try_new_async<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + 'this>> ) -> Result<DataAndRef, Error_>
(See also DataAndRefAsyncTryBuilder::try_build()
.) Like new
, but builders for self-referencing fields can return results. If any of them fail, Err
is returned. If all of them succeed, Ok
is returned. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) async fn try_new_or_recover_async<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + 'this>>
) -> Result<DataAndRef, (Error_, Heads)>
pub(crate) async fn try_new_or_recover_async<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + 'this>> ) -> Result<DataAndRef, (Error_, Heads)>
(See also DataAndRefAsyncTryBuilder::try_build_or_recover()
.) Like try_new
, but all head fields are returned in the case of an error. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) async fn try_new_async_send<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + Send + 'this>>
) -> Result<DataAndRef, Error_>
pub(crate) async fn try_new_async_send<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + Send + 'this>> ) -> Result<DataAndRef, Error_>
(See also DataAndRefAsyncSendTryBuilder::try_build()
.) Like new
, but builders for self-referencing fields can return results. If any of them fail, Err
is returned. If all of them succeed, Ok
is returned. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) async fn try_new_or_recover_async_send<Error_>(
data: i32,
data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + Send + 'this>>
) -> Result<DataAndRef, (Error_, Heads)>
pub(crate) async fn try_new_or_recover_async_send<Error_>( data: i32, data_ref_builder: impl for<'this> FnOnce(&'this i32) -> Pin<Box<dyn Future<Output = Result<&'this i32, Error_>> + Send + 'this>> ) -> Result<DataAndRef, (Error_, Heads)>
(See also DataAndRefAsyncSendTryBuilder::try_build_or_recover()
.) Like try_new
, but all head fields are returned in the case of an error. The arguments are as follows:
Argument | Suggested Use |
---|---|
data | Directly pass in the value this field should contain |
data_ref_builder | Use a function or closure: (data: &_) -> Result<data_ref: _, Error_> |
sourcepub(crate) fn with_data<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow i32) -> ReturnType
) -> ReturnType
pub(crate) fn with_data<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(&'outer_borrow i32) -> ReturnType ) -> ReturnType
Provides limited immutable access to data
. This method was generated because the contents of data
are immutably borrowed by other fields.
sourcepub(crate) fn borrow_data<'this>(&'this self) -> &'this i32
pub(crate) fn borrow_data<'this>(&'this self) -> &'this i32
Provides limited immutable access to data
. This method was generated because the contents of data
are immutably borrowed by other fields.
sourcepub(crate) fn with_data_ref<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(&'outer_borrow &'this i32) -> ReturnType
) -> ReturnType
pub(crate) fn with_data_ref<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(&'outer_borrow &'this i32) -> ReturnType ) -> ReturnType
Provides an immutable reference to data_ref
. This method was generated because data_ref
is a tail field.
sourcepub(crate) fn borrow_data_ref<'this>(&'this self) -> &'this &'this i32
pub(crate) fn borrow_data_ref<'this>(&'this self) -> &'this &'this i32
Provides an immutable reference to data_ref
. This method was generated because data_ref
is a tail field.
sourcepub(crate) fn with_data_ref_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this> FnOnce(&'outer_borrow mut &'this i32) -> ReturnType
) -> ReturnType
pub(crate) fn with_data_ref_mut<'outer_borrow, ReturnType>( &'outer_borrow mut self, user: impl for<'this> FnOnce(&'outer_borrow mut &'this i32) -> ReturnType ) -> ReturnType
Provides a mutable reference to data_ref
. This method was generated because data_ref
is a tail field. No borrow_data_ref_mut
function was generated because Rust’s borrow checker is currently unable to guarantee that such a method would be used safely.
sourcepub(crate) fn with<'outer_borrow, ReturnType>(
&'outer_borrow self,
user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this>) -> ReturnType
) -> ReturnType
pub(crate) fn with<'outer_borrow, ReturnType>( &'outer_borrow self, user: impl for<'this> FnOnce(BorrowedFields<'outer_borrow, 'this>) -> ReturnType ) -> ReturnType
This method provides immutable references to all tail and immutably borrowed fields.
sourcepub(crate) fn with_mut<'outer_borrow, ReturnType>(
&'outer_borrow mut self,
user: impl for<'this0, 'this1> FnOnce(BorrowedMutFields<'outer_borrow, 'this1, 'this0>) -> ReturnType
) -> ReturnType
pub(crate) fn with_mut<'outer_borrow, ReturnType>( &'outer_borrow mut self, user: impl for<'this0, 'this1> FnOnce(BorrowedMutFields<'outer_borrow, 'this1, 'this0>) -> ReturnType ) -> ReturnType
This method provides mutable references to all tail fields.
sourcepub(crate) fn into_heads(self) -> Heads
pub(crate) fn into_heads(self) -> Heads
This function drops all internally referencing fields and returns only the head fields of this struct.