pub async fn append_to_sequence(&mut self, url: &str, data: &[u8]) -> Result<()> {
        let safe_url = Safe::parse_url(url)?;
        if safe_url.content_version().is_some() {
            return Err(Error::InvalidInput(format!(
                "The target URL cannot contain a version: {}",
                url
            )));
        };

        let (safe_url, _) = self.parse_and_resolve_url(url).await?;

        let xorname = safe_url.xorname();
        let type_tag = safe_url.type_tag();
        let is_private = safe_url.data_type() == SafeDataType::PrivateSequence;

        // append to the data the data
        self.safe_client
            .append_to_sequence(data, xorname, type_tag, is_private)
            .await
    }
/// Append data to a Public Sequence on the network
///
/// ## Example
/// ```
/// # use sn_api::Safe;
/// # let mut safe = Safe::default();
/// # async_std::task::block_on(async {
/// #   safe.connect("", Some("fake-credentials")).await.unwrap();
///     let data1 = b"First in the sequence";
///     let xorurl = safe.sequence_create(data1, None, 20_000, false).await.unwrap();
///     let data2 = b"Second in the sequence";
///     safe.append_to_sequence(&xorurl, data2).await.unwrap();
///     let received_data = safe.sequence_get(&xorurl).await.unwrap();
///     assert_eq!(received_data, (1, data2.to_vec()));
/// # });
/// ```
Append data to a Public Sequence on the network
Append data to a Public Sequence on the network
pub async fn append_to_sequence(&mut self, url: &str, data: &[u8]) -> Result<()> {
        let safe_url = Safe::parse_url(url)?;
        if safe_url.content_version().is_some() {
            return Err(Error::InvalidInput(format!(
                "The target URL cannot contain a version: {}",
                url
            )));
        };
        let (safe_url, _) = self.parse_and_resolve_url(url).await?;
        let xorname = safe_url.xorname();
        let type_tag = safe_url.type_tag();
        let is_private = safe_url.data_type() == SafeDataType::PrivateSequence;
        // append to the data the data
        self.safe_client
            .append_to_sequence(data, xorname, type_tag, is_private)
            .await
    }
pub async fn append_to_sequence ( & mut self , url : & str , data : & [ u8 ] ) -> Result < ( ) > { let safe_url = Safe :: parse_url ( url ) ? ; if safe_url . content_version ( ) . is_some ( ) { return Err ( Error :: InvalidInput ( format ! ( " " url ) ) ) ; } ; let ( safe_url , _ ) = self . parse_and_resolve_url ( url ) . await ? ; let xorname = safe_url . xorname ( ) ; let type_tag = safe_url . type_tag ( ) ; let is_private = safe_url . data_type ( ) == SafeDataType :: PrivateSequence ; // append to the data the data self . safe_client . append_to_sequence ( data , xorname , type_tag , is_private ) . await }
Append data to a Public Sequence on the network
Append data to a Public Sequence on the network
&mut self
url
&str
data
&[u8]
example
None
use sn_api::safe;
None
let mut safe = safe::default();
None
async_std::task::block_on(async {
None
safe.connect("", some("fake-credentials")).await.unwrap();
let data1 = b"First in the sequence";
let xorurl = safe.sequence_create(data1, None, 20_000, false).await.unwrap();
let data2 = b"Second in the sequence";
safe.append_to_sequence(&xorurl, data2).await.unwrap();
let received_data = safe.sequence_get(&xorurl).await.unwrap();
assert_eq!(received_data, (1, data2.to_vec())).
let data1 = b " First in the sequence " ; let xorurl = safe . sequence_create ( data1 None 20_000 false ) . await . unwrap () ; let data2 = b " Second in the sequence " ; safe . append_to_sequence ( &xorurl data2 ) . await . unwrap () ; let received_data = safe . sequence_get ( &xorurl ) . await . unwrap () ; assert_eq! ( received_data ( 1 data2 . to_vec () )) .
});
None