[][src]Trait abin::IntoUnSync

pub trait IntoUnSync {
    type Target;
    fn un_sync_convert(self) -> Self::Target;
}

Converts self into the un-synchronized version.

See also IntoUnSyncView and UnSyncRef.

Associated Types

type Target

Loading content...

Required methods

fn un_sync_convert(self) -> Self::Target

Converts self into the un-synchronized version.

Note: Unlike the IntoUnSyncView this does not always just return a view, it might actually change the backend (depending on the implementation). This operation might be expensive - depending on the implementation (for example a reference counted binary must clone its data if there are multiple references to that binary). So if there's no good reason to use this, better use the IntoUnSyncView.

use abin::{NewSBin, SBin, BinFactory, Bin, IntoUnSync, AnyBin, IntoSync};
let string = "This is some string; content of the binary.";
let sync_bin : SBin = NewSBin::copy_from_slice(string.as_bytes());
function_wants_bin(sync_bin.un_sync_convert());

fn function_wants_bin(value : Bin) {
    // note: The 'value' is no longer sync. E.g. the reference counter of this binary
    // is no longer synchronized.
    assert_eq!("This is some string; content of the binary.".as_bytes(), value.as_slice());
    // we can also un-wrap it to be a synchronized bin again... in this case, this is
    // a cheap operation (since there are no other references to `value`).
    let _synchronized_again : SBin = value.into_sync();
}
Loading content...

Implementors

impl IntoUnSync for Bin[src]

This might actually do something, since this Bin could just be an un-synchronized view for a synchronized binary. In that case, the binary is converted.

type Target = Bin

impl IntoUnSync for SBin[src]

type Target = Bin

impl<TBin> IntoUnSync for AnyStr<TBin> where
    TBin: AnyBin
[src]

type Target = AnyStr<Bin>

Loading content...