Skip to content

Commit 9166b22

Browse files
authored
Merge pull request #6 from n0-computer/remove-entry-newtype
refactor: remove entry newtype
2 parents 3802d6f + 1d8c60d commit 9166b22

File tree

2 files changed

+22
-52
lines changed

2 files changed

+22
-52
lines changed

src/rpc/client/docs.rs

+7-52
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ use quic_rpc::{client::BoxedConnector, message::RpcMsg, Connector};
2020
use serde::{Deserialize, Serialize};
2121

2222
use super::flatten;
23-
#[doc(inline)]
24-
pub use crate::engine::{LiveEvent, Origin, SyncEvent, SyncReason};
2523
use crate::{
2624
actor::OpenState,
2725
rpc::proto::{
@@ -32,7 +30,12 @@ use crate::{
3230
StartSyncRequest, StatusRequest,
3331
},
3432
store::{DownloadPolicy, Query},
35-
AuthorId, Capability, CapabilityKind, DocTicket, NamespaceId, PeerIdBytes, RecordIdentifier,
33+
AuthorId, Capability, CapabilityKind, DocTicket, NamespaceId, PeerIdBytes,
34+
};
35+
#[doc(inline)]
36+
pub use crate::{
37+
engine::{LiveEvent, Origin, SyncEvent, SyncReason},
38+
Entry,
3639
};
3740

3841
/// Iroh docs client.
@@ -265,7 +268,7 @@ impl<C: Connector<RpcService>> Doc<C> {
265268
.0
266269
.rpc
267270
.server_streaming(ExportFileRequest {
268-
entry: entry.0,
271+
entry,
269272
path: path.as_ref().into(),
270273
mode,
271274
})
@@ -428,54 +431,6 @@ where
428431
}
429432
}
430433

431-
/// A single entry in a [`Doc`].
432-
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
433-
pub struct Entry(crate::Entry);
434-
435-
impl From<crate::Entry> for Entry {
436-
fn from(value: crate::Entry) -> Self {
437-
Self(value)
438-
}
439-
}
440-
441-
impl From<crate::SignedEntry> for Entry {
442-
fn from(value: crate::SignedEntry) -> Self {
443-
Self(value.into())
444-
}
445-
}
446-
447-
impl Entry {
448-
/// Returns the [`RecordIdentifier`] for this entry.
449-
pub fn id(&self) -> &RecordIdentifier {
450-
self.0.id()
451-
}
452-
453-
/// Returns the [`AuthorId`] of this entry.
454-
pub fn author(&self) -> AuthorId {
455-
self.0.author()
456-
}
457-
458-
/// Returns the [`struct@Hash`] of the content data of this record.
459-
pub fn content_hash(&self) -> Hash {
460-
self.0.content_hash()
461-
}
462-
463-
/// Returns the length of the data addressed by this record's content hash.
464-
pub fn content_len(&self) -> u64 {
465-
self.0.content_len()
466-
}
467-
468-
/// Returns the key of this entry.
469-
pub fn key(&self) -> &[u8] {
470-
self.0.key()
471-
}
472-
473-
/// Returns the timestamp of this entry.
474-
pub fn timestamp(&self) -> u64 {
475-
self.0.timestamp()
476-
}
477-
}
478-
479434
/// Progress messages for an doc import operation
480435
///
481436
/// An import operation involves computing the outboard of a file, and then

src/sync.rs

+15
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,21 @@ impl Entry {
945945
&self.record
946946
}
947947

948+
/// Get the content hash of the record.
949+
pub fn content_hash(&self) -> Hash {
950+
self.record.hash
951+
}
952+
953+
/// Get the content length of the record.
954+
pub fn content_len(&self) -> u64 {
955+
self.record.len
956+
}
957+
958+
/// Get the timestamp of the record.
959+
pub fn timestamp(&self) -> u64 {
960+
self.record.timestamp
961+
}
962+
948963
/// Serialize this entry into its canonical byte representation used for signing.
949964
pub fn encode(&self, out: &mut Vec<u8>) {
950965
self.id.encode(out);

0 commit comments

Comments
 (0)