@@ -31,7 +31,7 @@ use crate::{
31
31
use std:: ffi:: c_void;
32
32
use std:: marker:: PhantomData ;
33
33
34
- /** A binary attachment to a Document. */
34
+ /// A binary attachment to a Document
35
35
pub struct Blob {
36
36
pub ( crate ) cbl_ref : * const CBLBlob ,
37
37
}
@@ -46,7 +46,7 @@ impl CblRef for Blob {
46
46
impl Blob {
47
47
//////// CREATION
48
48
49
- /** Creates a new blob, given its contents as a byte array. */
49
+ /// Creates a new blob, given its contents as a byte array.
50
50
pub fn new_from_data ( data : & [ u8 ] , content_type : & str ) -> Self {
51
51
unsafe {
52
52
let blob = CBLBlob_CreateWithData (
@@ -57,8 +57,8 @@ impl Blob {
57
57
}
58
58
}
59
59
60
- /** Creates a new blob from data that has has been written to a [`Writer`].
61
- You should then add the blob to a document as a property, using [`Slot::put_blob`]. */
60
+ /// Creates a new blob from data that has has been written to a [`Writer`].
61
+ /// You should then add the blob to a document as a property, using [`Slot::put_blob`].
62
62
pub fn new_from_stream ( mut stream : BlobWriter , content_type : & str ) -> Self {
63
63
unsafe {
64
64
let blob = CBLBlob_CreateWithStream ( from_str ( content_type) . get_ref ( ) , stream. get_ref ( ) ) ;
@@ -67,7 +67,7 @@ impl Blob {
67
67
}
68
68
}
69
69
70
- // called by FleeceReference::as_blob()
70
+ /// called by FleeceReference::as_blob()
71
71
pub ( crate ) fn from_value < V : FleeceReference > ( value : & V ) -> Option < Self > {
72
72
unsafe {
73
73
let blob = FLDict_GetBlob ( FLValue_AsDict ( value. _fleece_ref ( ) ) ) ;
@@ -81,30 +81,30 @@ impl Blob {
81
81
82
82
//////// ACCESSORS
83
83
84
- /** The length of the content data in bytes. */
84
+ /// The length of the content data in bytes
85
85
pub fn length ( & self ) -> u64 {
86
86
unsafe { CBLBlob_Length ( self . get_ref ( ) ) }
87
87
}
88
88
89
- /** The unique digest of the blob: A base64-encoded SHA-1 digest of its data. */
89
+ /// The unique digest of the blob: A base64-encoded SHA-1 digest of its data
90
90
pub fn digest ( & self ) -> & str {
91
91
unsafe { CBLBlob_Digest ( self . get_ref ( ) ) . as_str ( ) . unwrap ( ) }
92
92
}
93
93
94
- /** The MIME type assigned to the blob, if any. */
94
+ /// The MIME type assigned to the blob, if any
95
95
pub fn content_type ( & self ) -> Option < & str > {
96
96
unsafe { CBLBlob_ContentType ( self . get_ref ( ) ) . as_str ( ) }
97
97
}
98
98
99
- /** The blob's metadata properties as a dictionary. */
99
+ /// The blob's metadata properties as a dictionary
100
100
pub fn properties ( & self ) -> Dict {
101
101
unsafe { Dict :: new ( CBLBlob_Properties ( self . get_ref ( ) ) ) }
102
102
}
103
103
104
104
//////// READING:
105
105
106
- /** Reads the blob's contents into memory and returns them as a byte array.
107
- This can potentially allocate a lot of memory! */
106
+ /// Reads the blob's contents into memory and returns them as a byte array.
107
+ /// This can potentially allocate a lot of memory!
108
108
pub fn load_content ( & self ) -> Result < Vec < u8 > > {
109
109
unsafe {
110
110
let mut err = CBLError :: default ( ) ;
@@ -113,7 +113,7 @@ impl Blob {
113
113
}
114
114
}
115
115
116
- /** Opens a stream for reading a blob's content from disk. */
116
+ /// Opens a stream for reading a blob's content from disk.
117
117
pub fn open_content ( & self ) -> Result < BlobReader > {
118
118
check_ptr (
119
119
|err| unsafe { CBLBlob_OpenContentStream ( self . get_ref ( ) , err) } ,
@@ -146,15 +146,15 @@ impl Clone for Blob {
146
146
//////// BLOB ADDITIONS FOR ARRAY / DICT:
147
147
148
148
impl Slot < ' _ > {
149
- /** Stores a Blob reference in an Array or Dict. This is how you add a Blob to a Document. */
149
+ /// Stores a Blob reference in an Array or Dict. This is how you add a Blob to a Document.
150
150
pub fn put_blob ( self , blob : & mut Blob ) {
151
151
unsafe { FLSlot_SetBlob ( self . get_ref ( ) , blob. get_ref ( ) as * mut CBLBlob ) }
152
152
}
153
153
}
154
154
155
155
//////// BLOB READER
156
156
157
- /** A stream for reading Blob conents. */
157
+ /// A stream for reading Blob conents
158
158
pub struct BlobReader < ' r > {
159
159
pub blob : & ' r Blob ,
160
160
stream_ref : * mut CBLBlobReadStream ,
@@ -192,9 +192,8 @@ impl Drop for BlobReader<'_> {
192
192
193
193
//////// BLOB WRITER
194
194
195
- /** A stream for writing data that will become a Blob's contents.
196
- After you're done writing the data, call [`Blob::new_from_stream`],
197
- then add the Blob to a document property via [`Slot::put_blob`]. */
195
+ /// A stream for writing data that will become a Blob's contents.
196
+ /// After you're done writing the data, call [`Blob::new_from_stream`], then add the Blob to a document property via [`Slot::put_blob`].
198
197
pub struct BlobWriter < ' d > {
199
198
stream_ref : * mut CBLBlobWriteStream ,
200
199
db : PhantomData < & ' d mut Database > ,
0 commit comments