Skip to content

Commit

Permalink
Remove SeekExt
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Oct 7, 2023
1 parent 30b4c9e commit 2a4eaf1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/hg_connect_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::libgit::{
credential_fill, curl_errorstr, die, get_active_slot, http_auth, http_follow_config,
run_one_slot, slot_results, ssl_cainfo, HTTP_OK, HTTP_REAUTH,
};
use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SeekExt, SliceExt, ToBoxed};
use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SliceExt, ToBoxed};

mod git_http_state {
use std::ffi::CString;
Expand Down Expand Up @@ -226,7 +226,7 @@ impl HttpRequest {
curl_easy_setopt(
slot.curl,
CURLOPT_POSTFIELDSIZE_LARGE,
body.stream_len_().unwrap(),
body.seek(SeekFrom::End(0)).unwrap(),
);
/* Ensure we have no state from a previous attempt that failed because
* of authentication (401). */
Expand Down
4 changes: 2 additions & 2 deletions src/hg_connect_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::hg_connect::{
use crate::libc::FdFile;
use crate::libcinnabar::{hg_connect_stdio, stdio_finish};
use crate::libgit::child_process;
use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt, SeekExt};
use crate::util::{ImmutBString, OsStrExt, PrefixWriter, ReadExt};

pub struct HgStdioConnection {
capabilities: HgCapabilities,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl HgWireConnection for HgStdioConnection {
self.proc_in.write_all(&header).unwrap();
drop(header);

let len = input.stream_len_().unwrap();
let len = input.metadata().unwrap().len();
//TODO: chunk in smaller pieces.
writeln!(self.proc_in, "{}", len).unwrap();

Expand Down
13 changes: 1 addition & 12 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use std::ffi::{CStr, CString, OsStr};
use std::io::{self, LineWriter, Read, Seek, SeekFrom, Write};
use std::io::{self, LineWriter, Read, Write};
#[cfg(unix)]
use std::os::unix::ffi;
#[cfg(windows)]
Expand Down Expand Up @@ -94,17 +94,6 @@ pub trait ReadExt: Read {

impl<T: Read> ReadExt for T {}

pub trait SeekExt: Seek {
fn stream_len_(&mut self) -> io::Result<u64> {
let old_pos = self.stream_position()?;
let len = self.seek(SeekFrom::End(0))?;
self.seek(SeekFrom::Start(old_pos))?;
Ok(len)
}
}

impl<T: Seek> SeekExt for T {}

pub trait SliceExt<C> {
fn splitn_exact<const N: usize>(&self, c: C) -> Option<[&Self; N]>;
fn rsplitn_exact<const N: usize>(&self, c: C) -> Option<[&Self; N]>;
Expand Down

0 comments on commit 2a4eaf1

Please sign in to comment.