pub struct Pin {
pub kind: String,
pub version: String,
pub metadata: Metadata,
pub spec: PinSpec,
pub status: Option<PinStatus>,
}
Expand description
Represents a Pin resource for storing data in the network
A Pin defines what data should be stored, for how long, and with what redundancy level. The data can be referenced either by CID or fallback URLs.
§Examples
Creating a Pin with CID:
use crate::models::{Pin, PinSpec, Metadata};
let pin = Pin {
kind: "Pin".to_string(),
version: "v0".to_string(),
metadata: Metadata {
name: "my-data".to_string(),
..Default::default()
},
spec: PinSpec {
cid: Some("QmExample123".to_string()),
bytes: "1GB".parse().unwrap(),
time: "24h".parse().unwrap(),
redundancy: 3,
fallback_urls: None,
},
status: None,
};
Creating a Pin with fallback URLs:
use crate::models::{Pin, PinSpec, Metadata};
let pin = Pin {
kind: "Pin".to_string(),
version: "v0".to_string(),
metadata: Metadata {
name: "my-backup".to_string(),
..Default::default()
},
spec: PinSpec {
cid: None,
bytes: "500MB".parse().unwrap(),
time: "7d".parse().unwrap(),
redundancy: 2,
fallback_urls: Some(vec![
"https://example.com/backup1".to_string(),
"https://backup.example.com/data".to_string()
]),
},
status: None,
};
Fields§
§kind: String
§version: String
§metadata: Metadata
§spec: PinSpec
§status: Option<PinStatus>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pin
impl<'de> Deserialize<'de> for Pin
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Pin
impl RefUnwindSafe for Pin
impl Send for Pin
impl Sync for Pin
impl Unpin for Pin
impl UnwindSafe for Pin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request